Skip to content

Commit

Permalink
refactor: improve the management of the panning cursor (#3017)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbouffard authored Jan 17, 2024
1 parent 9d78e11 commit 8d4308a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/component/mxgraph/GraphConfigurator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export default class GraphConfigurator {
const panningHandler = this.graph.panningHandler;
if (options?.navigation?.enabled) {
// Pan configuration
panningHandler.addListener(mxEvent.PAN_START, this.getPanningHandler('grab'));
panningHandler.addListener(mxEvent.PAN_END, this.getPanningHandler('default'));
panningHandler.addListener(mxEvent.PAN_START, setContainerCursor(this.graph, 'grab'));
panningHandler.addListener(mxEvent.PAN_END, setContainerCursor(this.graph, 'default'));

panningHandler.usePopupTrigger = false; // only use the left button to trigger panning
// Reimplement the function as we also want to trigger 'panning on cells' (ignoreCell to true) and only on left-click
Expand All @@ -87,10 +87,10 @@ export default class GraphConfigurator {
panningHandler.isForcePanningEvent = (_me: mxMouseEvent): boolean => false;
}
}
}

private getPanningHandler(cursor: 'grab' | 'default'): () => void {
return (): void => {
this.graph.isEnabled() && (this.container.style.cursor = cursor);
};
}
function setContainerCursor(graph: BpmnGraph, cursor: 'grab' | 'default'): () => void {
return (): void => {
graph.isEnabled() && (graph.container.style.cursor = cursor);
};
}

0 comments on commit 8d4308a

Please sign in to comment.