慕粉1753518858
我也没找到
慕粉3119754
define(['jquery'],function($){
function ScrollTo(opst){
this.opst =$.extend({},ScrollTo.DEFAULTS,opst);
//exend表示的是继承,'opst'表示传替参数给默认函数’scrollTo.DEFAULTS‘,覆盖成新函数传给"{}"
this.$el = $('html,body')
}
ScrollTo.prototype.move = function() {
var opst = this.opst,
des = opst.des
if($(window).scrollTop() != des){//如果滚动条不在指定的位置
if (!this.$el.is(':animated')) {
//如果页面不在滚动,':animated'注意属性this.$el.is(':animated') *animated
this.$el.animate({
scrollTop:des
},opst.speed);
}
}
};
ScrollTo.prototype.go = function() {
var des = this.opst.des
if($(window).scrollTop() != des){
this.$el .scrollTop(des);
}
}
//当没有值的时候,默认值
ScrollTo.DEFAULTS ={
des:0,
speed:800
};
return {
ScrollTo:ScrollTo
}
})