this.boundMouseUpHandler = this.handleMouseUp.bind(this);
this.boundToggleInteraction = this.toggleInteraction.bind(this);
this.boundCopyCode = this.copyCode.bind(this);
- this.boundZoomIn = () => {
- const { clientX, clientY } = this._getViewportCenterClientCoords();
- this.zoom(1, clientX, clientY);
- };
- this.boundZoomOut = () => {
- const { clientX, clientY } = this._getViewportCenterClientCoords();
- this.zoom(-1, clientX, clientY);
- };
+ this.boundZoomIn = this.handleZoomClick.bind(this, 1);
+ this.boundZoomOut = this.handleZoomClick.bind(this, -1);
this.boundResetZoom = this.resetZoom.bind(this);
this.boundHandleWheel = this.handleWheel.bind(this);
this.boundHandleMouseDown = this.handleMouseDown.bind(this);
this.content.style.transform = `translate(${this.translateX}px, ${this.translateY}px) scale(${this.scale})`;
}
+ handleZoomClick(direction) {
+ const { clientX, clientY } = this._getViewportCenterClientCoords();
+ this.zoom(direction, clientX, clientY);
+ }
+
handleWheel(e) {
if (!this.interactionEnabled) return;
// Prevent default browser scroll/zoom behavior when wheeling over the diagram