facilmap/frontend/app/ui/ui.js

17 wiersze
382 B
JavaScript

fm.app.directive("fmScrollToView", (fmUtils) => {
return {
restrict: 'A',
link: (scope, element, attrs) => {
let wasActiveBefore = false;
scope.$watch(attrs.fmScrollToView, (scrollToView) => {
scrollToView = !!scrollToView;
if(scrollToView && !wasActiveBefore) {
fmUtils.scrollIntoView(element);
}
wasActiveBefore = scrollToView;
});
}
};
});