add directive scrollIf, scroll to comment when reply

This commit is contained in:
OldHawk
2017-04-23 16:06:31 +08:00
parent 1fc901b0b3
commit 9620b6238d

View File

@@ -0,0 +1,27 @@
(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);
window.scrollTo(0, element[0].offsetTop - 60)
}
});
}
}
}());