...
|
...
|
@@ -39,12 +39,17 @@ var $ = require('yoho-jquery'); |
|
|
};
|
|
|
|
|
|
var utils = {
|
|
|
lock: false,
|
|
|
rollTo: function(el, toWhere) {
|
|
|
$(el).click(function() {
|
|
|
if ($(this).css('position') === 'fixed') {
|
|
|
utils.lock = true;
|
|
|
$('body').animate({
|
|
|
scrollTop: toWhere
|
|
|
}, 100);
|
|
|
setTimeout(function(){
|
|
|
utils.lock = false;
|
|
|
}, 500);
|
|
|
}
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -62,6 +67,7 @@ var $ = require('yoho-jquery'); |
|
|
this.preStyle = this.$el.attr('style');
|
|
|
this.preTop = originTop;
|
|
|
|
|
|
utils.lock = true;
|
|
|
this.$el.css({
|
|
|
position: 'fixed',
|
|
|
top: 0,
|
...
|
...
|
@@ -69,7 +75,9 @@ var $ = require('yoho-jquery'); |
|
|
});
|
|
|
|
|
|
this.isSet = true;
|
|
|
|
|
|
setTimeout(function(){
|
|
|
utils.lock = false;
|
|
|
}, 500);
|
|
|
if (settings.autoRollTop) {
|
|
|
utils.rollTo(this.$el.get(0), originTop);
|
|
|
}
|
...
|
...
|
@@ -97,6 +105,9 @@ var $ = require('yoho-jquery'); |
|
|
var originPoistion = $(el).offset().top;
|
|
|
|
|
|
$(window).scroll(function() {
|
|
|
if (utils.lock) {
|
|
|
return;
|
|
|
}
|
|
|
var elementTop = originPoistion - $(window).scrollTop();
|
|
|
|
|
|
if (scrollDirection.isDown() && elementTop <= 0) {
|
...
|
...
|
|