2017-10-12 00:56:17 +08:00
|
|
|
const Velocity = require('velocity-vector');
|
2015-11-27 23:37:40 +08:00
|
|
|
|
|
|
|
// courtesy of https://github.com/julianshapiro/velocity/issues/283
|
|
|
|
// We only use easeOutBounce (easeInBounce is just sort of nonsensical)
|
|
|
|
function bounce( p ) {
|
2018-10-27 11:50:35 +08:00
|
|
|
let pow2;
|
2018-10-27 12:03:57 +08:00
|
|
|
let bounce = 4;
|
2015-11-27 23:37:40 +08:00
|
|
|
|
2017-01-20 22:22:27 +08:00
|
|
|
while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {
|
|
|
|
// just sets pow2
|
|
|
|
}
|
2015-11-27 23:37:40 +08:00
|
|
|
return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
Velocity.Easings.easeOutBounce = function(p) {
|
|
|
|
return 1 - bounce(1 - p);
|
2017-01-20 22:22:27 +08:00
|
|
|
};
|