|
|
@@ -57,7 +57,7 @@ var panelTemplate = `
|
|
|
</div>
|
|
|
`;
|
|
|
|
|
|
-module.directive('grafanaPanel', function($rootScope, $document, $timeout) {
|
|
|
+module.directive('grafanaPanel', function($rootScope, $document) {
|
|
|
return {
|
|
|
restrict: 'E',
|
|
|
template: panelTemplate,
|
|
|
@@ -175,27 +175,28 @@ module.directive('grafanaPanel', function($rootScope, $document, $timeout) {
|
|
|
elem.on('mouseenter', mouseEnter);
|
|
|
elem.on('mouseleave', mouseLeave);
|
|
|
|
|
|
+ ctrl.isPanelVisible = function () {
|
|
|
+ var position = panelContainer[0].getBoundingClientRect();
|
|
|
+ return (0 < position.top) && (position.top < window.innerHeight);
|
|
|
+ };
|
|
|
+
|
|
|
+ const refreshOnScroll = _.debounce(function () {
|
|
|
+ if (ctrl.skippedLastRefresh) {
|
|
|
+ ctrl.refresh();
|
|
|
+ }
|
|
|
+ }, 250);
|
|
|
+
|
|
|
+ $document.on('scroll', refreshOnScroll);
|
|
|
+
|
|
|
scope.$on('$destroy', function() {
|
|
|
elem.off();
|
|
|
cornerInfoElem.off();
|
|
|
+ $document.off('scroll', refreshOnScroll);
|
|
|
|
|
|
if (infoDrop) {
|
|
|
infoDrop.destroy();
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- scope.needsRefresh = false;
|
|
|
-
|
|
|
- scope.isVisible = function () {
|
|
|
- var position = panelContainer[0].getBoundingClientRect();
|
|
|
- return (0 < position.top) && (position.top < window.innerHeight);
|
|
|
- };
|
|
|
-
|
|
|
- $document.bind('scroll', _.debounce(function () {
|
|
|
- if (scope.ctrl.dashboard.loadOnScroll && scope.needsRefresh) {
|
|
|
- scope.ctrl.refresh();
|
|
|
- }
|
|
|
- }, 250));
|
|
|
}
|
|
|
};
|
|
|
});
|