|
@@ -1,6 +1,7 @@
|
|
|
import angular from 'angular';
|
|
import angular from 'angular';
|
|
|
|
|
+import $ from 'jquery';
|
|
|
import Drop from 'tether-drop';
|
|
import Drop from 'tether-drop';
|
|
|
-import PerfectScrollbar from 'perfect-scrollbar';
|
|
|
|
|
|
|
+import baron from 'baron';
|
|
|
|
|
|
|
|
var module = angular.module('grafana.directives');
|
|
var module = angular.module('grafana.directives');
|
|
|
|
|
|
|
@@ -86,6 +87,9 @@ module.directive('grafanaPanel', function($rootScope, $document, $timeout) {
|
|
|
|
|
|
|
|
function panelHeightUpdated() {
|
|
function panelHeightUpdated() {
|
|
|
panelContent.css({ height: ctrl.height + 'px' });
|
|
panelContent.css({ height: ctrl.height + 'px' });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function resizeScrollableContent() {
|
|
|
if (panelScrollbar) {
|
|
if (panelScrollbar) {
|
|
|
panelScrollbar.update();
|
|
panelScrollbar.update();
|
|
|
}
|
|
}
|
|
@@ -100,8 +104,26 @@ module.directive('grafanaPanel', function($rootScope, $document, $timeout) {
|
|
|
// update scrollbar after mounting
|
|
// update scrollbar after mounting
|
|
|
ctrl.events.on('component-did-mount', () => {
|
|
ctrl.events.on('component-did-mount', () => {
|
|
|
if (ctrl.__proto__.constructor.scrollable) {
|
|
if (ctrl.__proto__.constructor.scrollable) {
|
|
|
- panelScrollbar = new PerfectScrollbar(panelContent[0], {
|
|
|
|
|
- wheelPropagation: true,
|
|
|
|
|
|
|
+ const scrollRootClass = 'baron baron__root baron__clipper panel-content--scrollable';
|
|
|
|
|
+ const scrollerClass = 'baron__scroller';
|
|
|
|
|
+ const scrollBarHTML = `
|
|
|
|
|
+ <div class="baron__track">
|
|
|
|
|
+ <div class="baron__bar"></div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ `;
|
|
|
|
|
+
|
|
|
|
|
+ let scrollRoot = panelContent;
|
|
|
|
|
+ let scroller = panelContent.find(':first-child').find(':first-child');
|
|
|
|
|
+ scrollRoot.addClass(scrollRootClass);
|
|
|
|
|
+ $(scrollBarHTML).appendTo(scrollRoot);
|
|
|
|
|
+ scroller.addClass(scrollerClass);
|
|
|
|
|
+
|
|
|
|
|
+ panelScrollbar = baron({
|
|
|
|
|
+ root: scrollRoot[0],
|
|
|
|
|
+ scroller: scroller[0],
|
|
|
|
|
+ bar: '.baron__bar',
|
|
|
|
|
+ barOnCls: '_scrollbar',
|
|
|
|
|
+ scrollingCls: '_scrolling',
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -110,6 +132,7 @@ module.directive('grafanaPanel', function($rootScope, $document, $timeout) {
|
|
|
ctrl.calculatePanelHeight();
|
|
ctrl.calculatePanelHeight();
|
|
|
panelHeightUpdated();
|
|
panelHeightUpdated();
|
|
|
$timeout(() => {
|
|
$timeout(() => {
|
|
|
|
|
+ resizeScrollableContent();
|
|
|
ctrl.render();
|
|
ctrl.render();
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
@@ -199,7 +222,7 @@ module.directive('grafanaPanel', function($rootScope, $document, $timeout) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (panelScrollbar) {
|
|
if (panelScrollbar) {
|
|
|
- panelScrollbar.update();
|
|
|
|
|
|
|
+ panelScrollbar.dispose();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|