mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
ux: fixed issue with zoom on graph caused scroll, fixes #10696
This commit is contained in:
parent
1303dc7ac0
commit
e985a9cd7c
@ -7,25 +7,29 @@ export function geminiScrollbar() {
|
|||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
link: function(scope, elem, attrs) {
|
link: function(scope, elem, attrs) {
|
||||||
let scrollbar = new PerfectScrollbar(elem[0]);
|
let scrollbar = new PerfectScrollbar(elem[0]);
|
||||||
|
let lastPos = 0;
|
||||||
|
|
||||||
appEvents.on(
|
appEvents.on(
|
||||||
'smooth-scroll-top',
|
'dash-scroll',
|
||||||
() => {
|
evt => {
|
||||||
elem.animate(
|
if (evt.restore) {
|
||||||
{
|
elem[0].scrollTop = lastPos;
|
||||||
scrollTop: 0,
|
return;
|
||||||
},
|
}
|
||||||
500
|
|
||||||
);
|
lastPos = elem[0].scrollTop;
|
||||||
|
|
||||||
|
if (evt.animate) {
|
||||||
|
elem.animate({ scrollTop: evt.pos }, 500);
|
||||||
|
} else {
|
||||||
|
elem[0].scrollTop = evt.pos;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
scope
|
scope
|
||||||
);
|
);
|
||||||
|
|
||||||
scope.$on('$routeChangeSuccess', () => {
|
scope.$on('$routeChangeSuccess', () => {
|
||||||
elem[0].scrollTop = 0;
|
lastPos = 0;
|
||||||
});
|
|
||||||
|
|
||||||
scope.$on('$routeUpdate', () => {
|
|
||||||
elem[0].scrollTop = 0;
|
elem[0].scrollTop = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -72,7 +72,8 @@ export class DashNavCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addPanel() {
|
addPanel() {
|
||||||
appEvents.emit('smooth-scroll-top');
|
appEvents.emit('dash-scroll', { animate: true, evt: 0 });
|
||||||
|
|
||||||
if (this.dashboard.panels.length > 0 && this.dashboard.panels[0].type === 'add-panel') {
|
if (this.dashboard.panels.length > 0 && this.dashboard.panels[0].type === 'add-panel') {
|
||||||
return; // Return if the "Add panel" exists already
|
return; // Return if the "Add panel" exists already
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,9 @@ export class SettingsCtrl {
|
|||||||
this.$scope.$on('$destroy', () => {
|
this.$scope.$on('$destroy', () => {
|
||||||
this.dashboard.updateSubmenuVisibility();
|
this.dashboard.updateSubmenuVisibility();
|
||||||
this.$rootScope.$broadcast('refresh');
|
this.$rootScope.$broadcast('refresh');
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$rootScope.appEvent('dash-scroll', { restore: true });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.canSaveAs = contextSrv.isEditor;
|
this.canSaveAs = contextSrv.isEditor;
|
||||||
@ -33,7 +36,8 @@ export class SettingsCtrl {
|
|||||||
this.buildSectionList();
|
this.buildSectionList();
|
||||||
this.onRouteUpdated();
|
this.onRouteUpdated();
|
||||||
|
|
||||||
$rootScope.onAppEvent('$routeUpdate', this.onRouteUpdated.bind(this), $scope);
|
this.$rootScope.onAppEvent('$routeUpdate', this.onRouteUpdated.bind(this), $scope);
|
||||||
|
this.$rootScope.appEvent('dash-scroll', { animate: false, pos: 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
buildSectionList() {
|
buildSectionList() {
|
||||||
|
@ -150,6 +150,7 @@ export class DashboardViewState {
|
|||||||
|
|
||||||
this.dashboard.setViewMode(ctrl.panel, false, false);
|
this.dashboard.setViewMode(ctrl.panel, false, false);
|
||||||
this.$scope.appEvent('panel-fullscreen-exit', { panelId: ctrl.panel.id });
|
this.$scope.appEvent('panel-fullscreen-exit', { panelId: ctrl.panel.id });
|
||||||
|
this.$scope.appEvent('dash-scroll', { restore: true });
|
||||||
|
|
||||||
if (!render) {
|
if (!render) {
|
||||||
return false;
|
return false;
|
||||||
@ -177,6 +178,7 @@ export class DashboardViewState {
|
|||||||
|
|
||||||
this.dashboard.setViewMode(ctrl.panel, true, ctrl.editMode);
|
this.dashboard.setViewMode(ctrl.panel, true, ctrl.editMode);
|
||||||
this.$scope.appEvent('panel-fullscreen-enter', { panelId: ctrl.panel.id });
|
this.$scope.appEvent('panel-fullscreen-enter', { panelId: ctrl.panel.id });
|
||||||
|
this.$scope.appEvent('dash-scroll', { animate: false, pos: 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
registerPanel(panelScope) {
|
registerPanel(panelScope) {
|
||||||
|
Loading…
Reference in New Issue
Block a user