This commit is contained in:
Your Name
2026-08-11 17:41:36 +08:00
parent cfe4c82c90
commit 03fe4ddf9d
18771 changed files with 3617239 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
var Tween = require('./Tween');
var defaults = require('./defaults');
var noop = require('./noop');
var isNum = require('./isNum');
var $offset = require('./$offset');
exports = function(target, options) {
options = options || {};
defaults(options, defOpts);
if (!isNum(target)) target = $offset(target).top;
new Tween({
y: window.pageYOffset
})
.on('update', function(target) {
window.scroll(0, target.y);
})
.on('end', function() {
options.callback();
})
.to(
{
y: target - options.tolerance
},
options.duration,
options.easing
)
.play();
};
var defOpts = {
tolerance: 0,
duration: 800,
easing: 'outQuart',
callback: noop
};
module.exports = exports;