mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* ux: When adding a new panel we should scroll to top until we figure out a better solution #10299 * ux: Use jquery to add smooth scrolling when scrolling up to add a panel, and make sure to pass the scope to the event emitter, #10299 * ux: Add a close button to the "New panel"-box and make sure you scroll to top every time you click "Add panel" #10299
40 lines
834 B
TypeScript
40 lines
834 B
TypeScript
import PerfectScrollbar from 'perfect-scrollbar';
|
|
import coreModule from 'app/core/core_module';
|
|
import appEvents from 'app/core/app_events';
|
|
|
|
export function geminiScrollbar() {
|
|
return {
|
|
restrict: 'A',
|
|
link: function(scope, elem, attrs) {
|
|
let scrollbar = new PerfectScrollbar(elem[0]);
|
|
|
|
appEvents.on(
|
|
'smooth-scroll-top',
|
|
() => {
|
|
elem.animate(
|
|
{
|
|
scrollTop: 0,
|
|
},
|
|
500
|
|
);
|
|
},
|
|
scope
|
|
);
|
|
|
|
scope.$on('$routeChangeSuccess', () => {
|
|
elem[0].scrollTop = 0;
|
|
});
|
|
|
|
scope.$on('$routeUpdate', () => {
|
|
elem[0].scrollTop = 0;
|
|
});
|
|
|
|
scope.$on('$destroy', () => {
|
|
scrollbar.destroy();
|
|
});
|
|
},
|
|
};
|
|
}
|
|
|
|
coreModule.directive('grafanaScrollbar', geminiScrollbar);
|