mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-26 03:30:48 +03:00
Fixes #498 Добавить возможность помимо scrollup-а, делать и scrolldown
This commit is contained in:
parent
e06bbadd17
commit
734eeceb80
|
@ -27,22 +27,63 @@
|
|||
* @private
|
||||
*/
|
||||
_create: function () {
|
||||
this._on( { 'click': this.up } );
|
||||
this._on( this.window, { 'scroll': this.check } );
|
||||
this._on( { 'click': this.onClick } );
|
||||
this._on( this.window, { 'scroll': this.onScroll } );
|
||||
},
|
||||
|
||||
/**
|
||||
* Показывает/скрывает кнопку прокрутки в зависимости от значения scrollTop
|
||||
*/
|
||||
check: function() {
|
||||
this.element[ this.window.scrollTop() > this.window.height() / 2 ? 'fadeIn' : 'fadeOut' ]( 500 );
|
||||
onScroll: function() {
|
||||
if ( this.prev && this.isTop && this.window.scrollTop() > 0 ) {
|
||||
this.element.removeClass( ls.options.classes.states.active );
|
||||
this.isTop = false;
|
||||
this.prev = null;
|
||||
}
|
||||
|
||||
! this.prev && this.element[ this.window.scrollTop() > this.window.height() / 2 ? 'fadeIn' : 'fadeOut' ]( 500 );
|
||||
},
|
||||
|
||||
/**
|
||||
* Обработка клика
|
||||
*/
|
||||
onClick: function() {
|
||||
// Не обрабатываем клики в процессе скролла
|
||||
! this.isScroll && this[ this.prev && this.isTop ? 'back' : 'up' ]();
|
||||
},
|
||||
|
||||
/**
|
||||
* Прокрутка вверх
|
||||
*/
|
||||
up: function() {
|
||||
$.scrollTo( 0, this.options.duration );
|
||||
this.prev = this.window.scrollTop();
|
||||
this.isScroll = true;
|
||||
|
||||
$.scrollTo( 0, this.options.duration, {
|
||||
onAfter: function () {
|
||||
this.isTop = true;
|
||||
this.isScroll = false;
|
||||
this.element.addClass( ls.options.classes.states.active );
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Прокрутка к предыдущей позиции
|
||||
*/
|
||||
back: function() {
|
||||
if ( ! this.prev ) return;
|
||||
|
||||
this.isTop = false;
|
||||
this.isScroll = true;
|
||||
|
||||
$.scrollTo( this.prev, this.options.duration, {
|
||||
onAfter: function () {
|
||||
this.element.removeClass( ls.options.classes.states.active );
|
||||
this.isScroll = false;
|
||||
this.prev = null;
|
||||
}.bind(this)
|
||||
});
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
|
@ -42,4 +42,6 @@
|
|||
*
|
||||
* @template toolbar/toolbar.scrollup.tpl
|
||||
*/
|
||||
.toolbar-item--scrollup { display: none; }
|
||||
.toolbar-item--scrollup { display: none; }
|
||||
.toolbar-item--scrollup i { background-position: -288px -120px; }
|
||||
.toolbar-item--scrollup.active i { background-position: -313px -119px; }
|
Loading…
Reference in a new issue