salix/front/core/components/scroll-up/scroll-up.js

35 lines
838 B
JavaScript

import ngModule from '../../module';
import Component from '../../lib/component';
import './style.scss';
export default class Controller extends Component {
constructor($element, $scope, $window) {
super($element, $scope);
this.$window = $window;
$window.addEventListener('scroll', () => {
if ($window.scrollY > 0)
$element[0].style.display = 'block';
else
$element[0].style.display = 'none';
});
}
goUp() {
this.$window.scrollTo(0, 0);
}
}
Controller.$inject = ['$element', '$scope', '$window'];
ngModule.vnComponent('vnScrollUp', {
template: require('./scroll-up.html'),
controller: Controller,
bindings: {
field: '=?',
options: '<?',
disabled: '<?',
checked: '<?'
}
});