mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-16 04:12:19 +01:00
29 lines
680 B
JavaScript
29 lines
680 B
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
angular.module('core')
|
|
.directive('scrollIf', scrollIf);
|
|
|
|
scrollIf.$inject = ['$uiViewScroll', '$location', '$anchorScroll'];
|
|
|
|
function scrollIf($uiViewScroll) {
|
|
var directive = {
|
|
restrict: 'A',
|
|
link: link
|
|
};
|
|
|
|
return directive;
|
|
|
|
function link(scope, element, attrs) {
|
|
scope.$watch(attrs.scrollIf, function (value) {
|
|
if (value) {
|
|
//element[0].scrollIntoView({block: 'end', behavior: 'smooth'});
|
|
//$uiViewScroll(element);
|
|
var offsetTop = Number(attrs.offsetTop || 0);
|
|
window.scrollTo(0, element[0].offsetTop + offsetTop);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}());
|