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

35 lines
838 B
JavaScript
Raw Permalink Normal View History

2019-09-05 11:06:40 +00:00
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'];
2020-07-24 15:46:06 +00:00
ngModule.vnComponent('vnScrollUp', {
2019-09-05 11:06:40 +00:00
template: require('./scroll-up.html'),
controller: Controller,
bindings: {
field: '=?',
options: '<?',
disabled: '<?',
checked: '<?'
}
});