课程/JavaScript/前端开发
侧栏工具条开发
-
-
Ruil
2016-03-14
- define(["jquery", "scrollto"], function($, scrollto) {
function BackTop(el, opts) {
this.opts = $.extend({}, BackTop.DEFAULTS, opts);
this.$el = $(el);
this.scrollto = new scrollto.ScrollTo({
dest: 20,
speed: this.opts.speed
});
if (this.opts.mode == "move") {
this.$el.on("click", $.proxy(this._move, this));
} else {
this.$el.on("click", $.proxy(this._go, this));
}
$(window).on("scroll", $.proxy(this._checkPosition, this));
};
BackTop.DEFAULTS = {
mode: "move",
pos: $(window).height(),
speed: 800
};
BackTop.prototype._move = function() {
this.scrollto.move();
};
BackTop.prototype._gp = function() {
this.scrollto.go();
};
BackTop.prototype._checkPosition = function() {
if ($(window).scrollTop() > this.opts.pos) {
this.$el.fadeIn();
} else {
this.$el.fadeOut();
}
};
return {
BackTop: BackTop
};
});
-
截图
1赞 · 0采集
-
-
超哥_1
2015-12-15
- 模块化工具条
-
截图
0赞 · 0采集
-
-
haleywang_com
2015-09-09
- 封装成模块
-
截图
0赞 · 0采集
-
-
longming
2015-08-24
- 用on来绑定事件和触发的函数,函数可以写在内部,只供内部调用,不对外提供接口,注意$.proxy,_function来表示内部方法
-
0赞 · 0采集
-
-
longming
2015-08-24
- 用on来绑定事件和触发的函数,函数可以写在内部,只供内部调用,不对外提供接口,注意$.proxy,_function来表示内部方法
-
截图
0赞 · 0采集
-
-
longming
2015-08-20
- 下划线表示只供局部使用,外部不要调用,
-
截图
0赞 · 0采集
-
-
longming
2015-08-19
- _下划线表示,改方法是仅供内部实用的,外部就不要调用了,
-
截图
1赞 · 2采集