mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-05-06 03:18:19 +02:00
add directive scrollIf, scroll to comment when reply
This commit is contained in:
27
modules/core/client/directives/scrollIf.client.directive.js
Normal file
27
modules/core/client/directives/scrollIf.client.directive.js
Normal 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)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}());
|
||||
Reference in New Issue
Block a user