jam-cloud/jam-ui/node_modules/react-scroll/modules/mixins/smooth.js

71 lines
2.0 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = {
/*
* https://github.com/oblador/angular-scroll (duScrollDefaultEasing)
*/
defaultEasing: function defaultEasing(x) {
if (x < 0.5) {
return Math.pow(x * 2, 2) / 2;
}
return 1 - Math.pow((1 - x) * 2, 2) / 2;
},
/*
* https://gist.github.com/gre/1650294
*/
// no easing, no acceleration
linear: function linear(x) {
return x;
},
// accelerating from zero velocity
easeInQuad: function easeInQuad(x) {
return x * x;
},
// decelerating to zero velocity
easeOutQuad: function easeOutQuad(x) {
return x * (2 - x);
},
// acceleration until halfway, then deceleration
easeInOutQuad: function easeInOutQuad(x) {
return x < .5 ? 2 * x * x : -1 + (4 - 2 * x) * x;
},
// accelerating from zero velocity
easeInCubic: function easeInCubic(x) {
return x * x * x;
},
// decelerating to zero velocity π
easeOutCubic: function easeOutCubic(x) {
return --x * x * x + 1;
},
// acceleration until halfway, then deceleration
easeInOutCubic: function easeInOutCubic(x) {
return x < .5 ? 4 * x * x * x : (x - 1) * (2 * x - 2) * (2 * x - 2) + 1;
},
// accelerating from zero velocity
easeInQuart: function easeInQuart(x) {
return x * x * x * x;
},
// decelerating to zero velocity
easeOutQuart: function easeOutQuart(x) {
return 1 - --x * x * x * x;
},
// acceleration until halfway, then deceleration
easeInOutQuart: function easeInOutQuart(x) {
return x < .5 ? 8 * x * x * x * x : 1 - 8 * --x * x * x * x;
},
// accelerating from zero velocity
easeInQuint: function easeInQuint(x) {
return x * x * x * x * x;
},
// decelerating to zero velocity
easeOutQuint: function easeOutQuint(x) {
return 1 + --x * x * x * x * x;
},
// acceleration until halfway, then deceleration
easeInOutQuint: function easeInOutQuint(x) {
return x < .5 ? 16 * x * x * x * x * x : 1 + 16 * --x * x * x * x * x;
}
};