mirror of
https://github.com/micku7zu/vanilla-tilt.js
synced 2024-06-20 06:24:59 +02:00
Update to version 1.8.0
This commit is contained in:
parent
bfe0c75eb5
commit
7a179baa43
42
dist/vanilla-tilt.babel.js
vendored
42
dist/vanilla-tilt.babel.js
vendored
|
@ -11,7 +11,7 @@ var classCallCheck = function (instance, Constructor) {
|
|||
* Created by Sergiu Șandor (micku7zu) on 1/27/2017.
|
||||
* Original idea: https://github.com/gijsroge/tilt.js
|
||||
* MIT License.
|
||||
* Version 1.7.3
|
||||
* Version 1.8.0
|
||||
*/
|
||||
|
||||
var VanillaTilt = function () {
|
||||
|
@ -47,6 +47,7 @@ var VanillaTilt = function () {
|
|||
this.settings = this.extendSettings(settings);
|
||||
|
||||
this.reverse = this.settings.reverse ? -1 : 1;
|
||||
this.resetToStart = VanillaTilt.isSettingTrue(this.settings["reset-to-start"]);
|
||||
this.glare = VanillaTilt.isSettingTrue(this.settings.glare);
|
||||
this.glarePrerender = VanillaTilt.isSettingTrue(this.settings["glare-prerender"]);
|
||||
this.fullPageListening = VanillaTilt.isSettingTrue(this.settings["full-page-listening"]);
|
||||
|
@ -65,7 +66,11 @@ var VanillaTilt = function () {
|
|||
|
||||
this.addEventListeners();
|
||||
this.reset();
|
||||
this.updateInitialPosition();
|
||||
|
||||
if (this.resetToStart === false) {
|
||||
this.settings.startX = 0;
|
||||
this.settings.startY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
VanillaTilt.isSettingTrue = function isSettingTrue(setting) {
|
||||
|
@ -228,30 +233,6 @@ var VanillaTilt = function () {
|
|||
};
|
||||
|
||||
VanillaTilt.prototype.reset = function reset() {
|
||||
this.event = {
|
||||
clientX: this.left + this.width / 2,
|
||||
clientY: this.top + this.height / 2
|
||||
};
|
||||
|
||||
if (this.element && this.element.style) {
|
||||
this.element.style.transform = "perspective(" + this.settings.perspective + "px) " + "rotateX(0deg) " + "rotateY(0deg) " + "scale3d(1, 1, 1)";
|
||||
}
|
||||
|
||||
this.resetGlare();
|
||||
};
|
||||
|
||||
VanillaTilt.prototype.resetGlare = function resetGlare() {
|
||||
if (this.glare) {
|
||||
this.glareElement.style.transform = "rotate(180deg) translate(-50%, -50%)";
|
||||
this.glareElement.style.opacity = "0";
|
||||
}
|
||||
};
|
||||
|
||||
VanillaTilt.prototype.updateInitialPosition = function updateInitialPosition() {
|
||||
if (this.settings.startX === 0 && this.settings.startY === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.onMouseEnter();
|
||||
|
||||
if (this.fullPageListening) {
|
||||
|
@ -273,6 +254,13 @@ var VanillaTilt = function () {
|
|||
this.resetGlare();
|
||||
};
|
||||
|
||||
VanillaTilt.prototype.resetGlare = function resetGlare() {
|
||||
if (this.glare) {
|
||||
this.glareElement.style.transform = "rotate(180deg) translate(-50%, -50%)";
|
||||
this.glareElement.style.opacity = "0";
|
||||
}
|
||||
};
|
||||
|
||||
VanillaTilt.prototype.getValues = function getValues() {
|
||||
var x = void 0,
|
||||
y = void 0;
|
||||
|
@ -434,6 +422,7 @@ var VanillaTilt = function () {
|
|||
* @param {boolean} settings.full-page-listening - If true, parallax effect will listen to mouse move events on the whole document, not only the selected element
|
||||
* @param {string|object} settings.mouse-event-element - String selector or link to HTML-element what will be listen mouse events
|
||||
* @param {boolean} settings.reset - false = If the tilt effect has to be reset on exit
|
||||
* @param {boolean} settings.reset-to-start - true = On reset event (mouse leave) will return to initial start angle (if startX or startY is set)
|
||||
* @param {gyroscope} settings.gyroscope - Enable tilting by deviceorientation events
|
||||
* @param {gyroscopeSensitivity} settings.gyroscopeSensitivity - Between 0 and 1 - The angle at which max tilt position is reached. 1 = 90deg, 0.5 = 45deg, etc..
|
||||
* @param {gyroscopeSamples} settings.gyroscopeSamples - How many gyroscope moves to decide the starting position.
|
||||
|
@ -458,6 +447,7 @@ var VanillaTilt = function () {
|
|||
"full-page-listening": false,
|
||||
"mouse-event-element": null,
|
||||
reset: true,
|
||||
"reset-to-start": true,
|
||||
gyroscope: true,
|
||||
gyroscopeMinAngleX: -45,
|
||||
gyroscopeMaxAngleX: 45,
|
||||
|
|
2
dist/vanilla-tilt.babel.min.js
vendored
2
dist/vanilla-tilt.babel.min.js
vendored
File diff suppressed because one or more lines are too long
50
dist/vanilla-tilt.js
vendored
50
dist/vanilla-tilt.js
vendored
|
@ -5,7 +5,7 @@ var VanillaTilt = (function () {
|
|||
* Created by Sergiu Șandor (micku7zu) on 1/27/2017.
|
||||
* Original idea: https://github.com/gijsroge/tilt.js
|
||||
* MIT License.
|
||||
* Version 1.7.3
|
||||
* Version 1.8.0
|
||||
*/
|
||||
|
||||
class VanillaTilt {
|
||||
|
@ -38,6 +38,7 @@ class VanillaTilt {
|
|||
this.settings = this.extendSettings(settings);
|
||||
|
||||
this.reverse = this.settings.reverse ? -1 : 1;
|
||||
this.resetToStart = VanillaTilt.isSettingTrue(this.settings["reset-to-start"]);
|
||||
this.glare = VanillaTilt.isSettingTrue(this.settings.glare);
|
||||
this.glarePrerender = VanillaTilt.isSettingTrue(this.settings["glare-prerender"]);
|
||||
this.fullPageListening = VanillaTilt.isSettingTrue(this.settings["full-page-listening"]);
|
||||
|
@ -56,7 +57,11 @@ class VanillaTilt {
|
|||
|
||||
this.addEventListeners();
|
||||
this.reset();
|
||||
this.updateInitialPosition();
|
||||
|
||||
if (this.resetToStart === false) {
|
||||
this.settings.startX = 0;
|
||||
this.settings.startY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static isSettingTrue(setting) {
|
||||
|
@ -213,33 +218,6 @@ class VanillaTilt {
|
|||
}
|
||||
|
||||
reset() {
|
||||
this.event = {
|
||||
clientX: this.left + this.width / 2,
|
||||
clientY: this.top + this.height / 2
|
||||
};
|
||||
|
||||
if (this.element && this.element.style) {
|
||||
this.element.style.transform = `perspective(${this.settings.perspective}px) ` +
|
||||
`rotateX(0deg) ` +
|
||||
`rotateY(0deg) ` +
|
||||
`scale3d(1, 1, 1)`;
|
||||
}
|
||||
|
||||
this.resetGlare();
|
||||
}
|
||||
|
||||
resetGlare() {
|
||||
if (this.glare) {
|
||||
this.glareElement.style.transform = "rotate(180deg) translate(-50%, -50%)";
|
||||
this.glareElement.style.opacity = "0";
|
||||
}
|
||||
}
|
||||
|
||||
updateInitialPosition() {
|
||||
if (this.settings.startX === 0 && this.settings.startY === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.onMouseEnter();
|
||||
|
||||
if (this.fullPageListening) {
|
||||
|
@ -254,7 +232,6 @@ class VanillaTilt {
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
let backupScale = this.settings.scale;
|
||||
this.settings.scale = 1;
|
||||
this.update();
|
||||
|
@ -262,6 +239,13 @@ class VanillaTilt {
|
|||
this.resetGlare();
|
||||
}
|
||||
|
||||
resetGlare() {
|
||||
if (this.glare) {
|
||||
this.glareElement.style.transform = "rotate(180deg) translate(-50%, -50%)";
|
||||
this.glareElement.style.opacity = "0";
|
||||
}
|
||||
}
|
||||
|
||||
getValues() {
|
||||
let x, y;
|
||||
|
||||
|
@ -351,7 +335,7 @@ class VanillaTilt {
|
|||
"height": "100%",
|
||||
"overflow": "hidden",
|
||||
"pointer-events": "none",
|
||||
"border-radius": "inherit",
|
||||
"border-radius": "inherit"
|
||||
});
|
||||
|
||||
Object.assign(this.glareElement.style, {
|
||||
|
@ -362,7 +346,7 @@ class VanillaTilt {
|
|||
"background-image": `linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%)`,
|
||||
"transform": "rotate(180deg) translate(-50%, -50%)",
|
||||
"transform-origin": "0% 0%",
|
||||
"opacity": "0",
|
||||
"opacity": "0"
|
||||
});
|
||||
|
||||
this.updateGlareSize();
|
||||
|
@ -426,6 +410,7 @@ class VanillaTilt {
|
|||
* @param {boolean} settings.full-page-listening - If true, parallax effect will listen to mouse move events on the whole document, not only the selected element
|
||||
* @param {string|object} settings.mouse-event-element - String selector or link to HTML-element what will be listen mouse events
|
||||
* @param {boolean} settings.reset - false = If the tilt effect has to be reset on exit
|
||||
* @param {boolean} settings.reset-to-start - true = On reset event (mouse leave) will return to initial start angle (if startX or startY is set)
|
||||
* @param {gyroscope} settings.gyroscope - Enable tilting by deviceorientation events
|
||||
* @param {gyroscopeSensitivity} settings.gyroscopeSensitivity - Between 0 and 1 - The angle at which max tilt position is reached. 1 = 90deg, 0.5 = 45deg, etc..
|
||||
* @param {gyroscopeSamples} settings.gyroscopeSamples - How many gyroscope moves to decide the starting position.
|
||||
|
@ -448,6 +433,7 @@ class VanillaTilt {
|
|||
"full-page-listening": false,
|
||||
"mouse-event-element": null,
|
||||
reset: true,
|
||||
"reset-to-start": true,
|
||||
gyroscope: true,
|
||||
gyroscopeMinAngleX: -45,
|
||||
gyroscopeMaxAngleX: 45,
|
||||
|
|
2
dist/vanilla-tilt.min.js
vendored
2
dist/vanilla-tilt.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -33,6 +33,7 @@ If you want to use this library in IE, you need to include a CustomEvent polyfil
|
|||
transition: true, // Set a transition on enter/exit.
|
||||
axis: null, // What axis should be enabled. Can be "x" or "y".
|
||||
reset: true, // If the tilt effect has to be reset on exit.
|
||||
"reset-to-start": true, // Whether the exit reset will go to [0,0] (default) or [startX, startY]
|
||||
easing: "cubic-bezier(.03,.98,.52,.99)", // Easing on enter/exit.
|
||||
glare: false, // if it should have a "glare" effect
|
||||
"max-glare": 1, // the maximum "glare" opacity (1 = 100%, 0.5 = 50%)
|
||||
|
@ -114,6 +115,7 @@ Original library author: [Gijs Rogé](https://twitter.com/GijsRoge)
|
|||
- [Corey Austin](https://github.com/lazyhummingbird) (Initial gyroscope position)
|
||||
- [Sander Moolin](https://github.com/SaFrMo)
|
||||
- [rrroyal](https://github.com/rrroyal) (Whole document mouse events listening)
|
||||
- [Andžs Pilskalns](https://github.com/Pilskalns) ("reset-to-start" feature)
|
||||
|
||||
### Other projects
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Created by Sergiu Șandor (micku7zu) on 1/27/2017.
|
||||
* Original idea: https://github.com/gijsroge/tilt.js
|
||||
* MIT License.
|
||||
* Version 1.7.3
|
||||
* Version 1.8.0
|
||||
*/
|
||||
|
||||
class VanillaTilt {
|
||||
|
@ -35,6 +35,7 @@ class VanillaTilt {
|
|||
this.settings = this.extendSettings(settings);
|
||||
|
||||
this.reverse = this.settings.reverse ? -1 : 1;
|
||||
this.resetToStart = VanillaTilt.isSettingTrue(this.settings["reset-to-start"]);
|
||||
this.glare = VanillaTilt.isSettingTrue(this.settings.glare);
|
||||
this.glarePrerender = VanillaTilt.isSettingTrue(this.settings["glare-prerender"]);
|
||||
this.fullPageListening = VanillaTilt.isSettingTrue(this.settings["full-page-listening"]);
|
||||
|
@ -53,7 +54,11 @@ class VanillaTilt {
|
|||
|
||||
this.addEventListeners();
|
||||
this.reset();
|
||||
this.updateInitialPosition();
|
||||
|
||||
if (this.resetToStart === false) {
|
||||
this.settings.startX = 0;
|
||||
this.settings.startY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static isSettingTrue(setting) {
|
||||
|
@ -210,33 +215,6 @@ class VanillaTilt {
|
|||
}
|
||||
|
||||
reset() {
|
||||
this.event = {
|
||||
clientX: this.left + this.width / 2,
|
||||
clientY: this.top + this.height / 2
|
||||
};
|
||||
|
||||
if (this.element && this.element.style) {
|
||||
this.element.style.transform = `perspective(${this.settings.perspective}px) ` +
|
||||
`rotateX(0deg) ` +
|
||||
`rotateY(0deg) ` +
|
||||
`scale3d(1, 1, 1)`;
|
||||
}
|
||||
|
||||
this.resetGlare();
|
||||
}
|
||||
|
||||
resetGlare() {
|
||||
if (this.glare) {
|
||||
this.glareElement.style.transform = "rotate(180deg) translate(-50%, -50%)";
|
||||
this.glareElement.style.opacity = "0";
|
||||
}
|
||||
}
|
||||
|
||||
updateInitialPosition() {
|
||||
if (this.settings.startX === 0 && this.settings.startY === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.onMouseEnter();
|
||||
|
||||
if (this.fullPageListening) {
|
||||
|
@ -251,7 +229,6 @@ class VanillaTilt {
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
let backupScale = this.settings.scale;
|
||||
this.settings.scale = 1;
|
||||
this.update();
|
||||
|
@ -259,6 +236,13 @@ class VanillaTilt {
|
|||
this.resetGlare();
|
||||
}
|
||||
|
||||
resetGlare() {
|
||||
if (this.glare) {
|
||||
this.glareElement.style.transform = "rotate(180deg) translate(-50%, -50%)";
|
||||
this.glareElement.style.opacity = "0";
|
||||
}
|
||||
}
|
||||
|
||||
getValues() {
|
||||
let x, y;
|
||||
|
||||
|
@ -348,7 +332,7 @@ class VanillaTilt {
|
|||
"height": "100%",
|
||||
"overflow": "hidden",
|
||||
"pointer-events": "none",
|
||||
"border-radius": "inherit",
|
||||
"border-radius": "inherit"
|
||||
});
|
||||
|
||||
Object.assign(this.glareElement.style, {
|
||||
|
@ -359,7 +343,7 @@ class VanillaTilt {
|
|||
"background-image": `linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%)`,
|
||||
"transform": "rotate(180deg) translate(-50%, -50%)",
|
||||
"transform-origin": "0% 0%",
|
||||
"opacity": "0",
|
||||
"opacity": "0"
|
||||
});
|
||||
|
||||
this.updateGlareSize();
|
||||
|
@ -423,6 +407,7 @@ class VanillaTilt {
|
|||
* @param {boolean} settings.full-page-listening - If true, parallax effect will listen to mouse move events on the whole document, not only the selected element
|
||||
* @param {string|object} settings.mouse-event-element - String selector or link to HTML-element what will be listen mouse events
|
||||
* @param {boolean} settings.reset - false = If the tilt effect has to be reset on exit
|
||||
* @param {boolean} settings.reset-to-start - true = On reset event (mouse leave) will return to initial start angle (if startX or startY is set)
|
||||
* @param {gyroscope} settings.gyroscope - Enable tilting by deviceorientation events
|
||||
* @param {gyroscopeSensitivity} settings.gyroscopeSensitivity - Between 0 and 1 - The angle at which max tilt position is reached. 1 = 90deg, 0.5 = 45deg, etc..
|
||||
* @param {gyroscopeSamples} settings.gyroscopeSamples - How many gyroscope moves to decide the starting position.
|
||||
|
@ -445,6 +430,7 @@ class VanillaTilt {
|
|||
"full-page-listening": false,
|
||||
"mouse-event-element": null,
|
||||
reset: true,
|
||||
"reset-to-start": true,
|
||||
gyroscope: true,
|
||||
gyroscopeMinAngleX: -45,
|
||||
gyroscopeMaxAngleX: 45,
|
||||
|
|
|
@ -10,7 +10,7 @@ var classCallCheck = function (instance, Constructor) {
|
|||
* Created by Sergiu Șandor (micku7zu) on 1/27/2017.
|
||||
* Original idea: https://github.com/gijsroge/tilt.js
|
||||
* MIT License.
|
||||
* Version 1.7.3
|
||||
* Version 1.8.0
|
||||
*/
|
||||
|
||||
var VanillaTilt = function () {
|
||||
|
@ -46,6 +46,7 @@ var VanillaTilt = function () {
|
|||
this.settings = this.extendSettings(settings);
|
||||
|
||||
this.reverse = this.settings.reverse ? -1 : 1;
|
||||
this.resetToStart = VanillaTilt.isSettingTrue(this.settings["reset-to-start"]);
|
||||
this.glare = VanillaTilt.isSettingTrue(this.settings.glare);
|
||||
this.glarePrerender = VanillaTilt.isSettingTrue(this.settings["glare-prerender"]);
|
||||
this.fullPageListening = VanillaTilt.isSettingTrue(this.settings["full-page-listening"]);
|
||||
|
@ -64,7 +65,11 @@ var VanillaTilt = function () {
|
|||
|
||||
this.addEventListeners();
|
||||
this.reset();
|
||||
this.updateInitialPosition();
|
||||
|
||||
if (this.resetToStart === false) {
|
||||
this.settings.startX = 0;
|
||||
this.settings.startY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
VanillaTilt.isSettingTrue = function isSettingTrue(setting) {
|
||||
|
@ -227,30 +232,6 @@ var VanillaTilt = function () {
|
|||
};
|
||||
|
||||
VanillaTilt.prototype.reset = function reset() {
|
||||
this.event = {
|
||||
clientX: this.left + this.width / 2,
|
||||
clientY: this.top + this.height / 2
|
||||
};
|
||||
|
||||
if (this.element && this.element.style) {
|
||||
this.element.style.transform = "perspective(" + this.settings.perspective + "px) " + "rotateX(0deg) " + "rotateY(0deg) " + "scale3d(1, 1, 1)";
|
||||
}
|
||||
|
||||
this.resetGlare();
|
||||
};
|
||||
|
||||
VanillaTilt.prototype.resetGlare = function resetGlare() {
|
||||
if (this.glare) {
|
||||
this.glareElement.style.transform = "rotate(180deg) translate(-50%, -50%)";
|
||||
this.glareElement.style.opacity = "0";
|
||||
}
|
||||
};
|
||||
|
||||
VanillaTilt.prototype.updateInitialPosition = function updateInitialPosition() {
|
||||
if (this.settings.startX === 0 && this.settings.startY === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.onMouseEnter();
|
||||
|
||||
if (this.fullPageListening) {
|
||||
|
@ -272,6 +253,13 @@ var VanillaTilt = function () {
|
|||
this.resetGlare();
|
||||
};
|
||||
|
||||
VanillaTilt.prototype.resetGlare = function resetGlare() {
|
||||
if (this.glare) {
|
||||
this.glareElement.style.transform = "rotate(180deg) translate(-50%, -50%)";
|
||||
this.glareElement.style.opacity = "0";
|
||||
}
|
||||
};
|
||||
|
||||
VanillaTilt.prototype.getValues = function getValues() {
|
||||
var x = void 0,
|
||||
y = void 0;
|
||||
|
@ -433,6 +421,7 @@ var VanillaTilt = function () {
|
|||
* @param {boolean} settings.full-page-listening - If true, parallax effect will listen to mouse move events on the whole document, not only the selected element
|
||||
* @param {string|object} settings.mouse-event-element - String selector or link to HTML-element what will be listen mouse events
|
||||
* @param {boolean} settings.reset - false = If the tilt effect has to be reset on exit
|
||||
* @param {boolean} settings.reset-to-start - true = On reset event (mouse leave) will return to initial start angle (if startX or startY is set)
|
||||
* @param {gyroscope} settings.gyroscope - Enable tilting by deviceorientation events
|
||||
* @param {gyroscopeSensitivity} settings.gyroscopeSensitivity - Between 0 and 1 - The angle at which max tilt position is reached. 1 = 90deg, 0.5 = 45deg, etc..
|
||||
* @param {gyroscopeSamples} settings.gyroscopeSamples - How many gyroscope moves to decide the starting position.
|
||||
|
@ -457,6 +446,7 @@ var VanillaTilt = function () {
|
|||
"full-page-listening": false,
|
||||
"mouse-event-element": null,
|
||||
reset: true,
|
||||
"reset-to-start": true,
|
||||
gyroscope: true,
|
||||
gyroscopeMinAngleX: -45,
|
||||
gyroscopeMaxAngleX: 45,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "vanilla-tilt",
|
||||
"version": "1.7.3",
|
||||
"version": "1.8.0",
|
||||
"description": "A smooth 3D tilt javascript library forked from Tilt.js",
|
||||
"main": "lib/vanilla-tilt.js",
|
||||
"module_es2015": "lib/vanilla-tilt.es2015.js",
|
||||
|
|
6
vanilla-tilt.d.ts
vendored
6
vanilla-tilt.d.ts
vendored
|
@ -1,4 +1,4 @@
|
|||
// Extended Type definitions for vanilla-tilt 1.7.3
|
||||
// Extended Type definitions for vanilla-tilt 1.8.0
|
||||
// Project: https://github.com/micku7zu/vanilla-tilt.js
|
||||
// Definitions by: Livio Brunner <https://github.com/BrunnerLivio>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
@ -50,6 +50,10 @@ export interface TiltOptions {
|
|||
* If the tilt effect has to be reset on exit.
|
||||
*/
|
||||
reset?: boolean;
|
||||
/**
|
||||
* Whether the exit reset will go to [0,0] (default) or [startX, startY].
|
||||
*/
|
||||
"reset-to-start"?: boolean;
|
||||
/**
|
||||
* Easing on enter/exit.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue