From 0da13a79408300e2ce56745c32d0cd29df3949d9 Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 12 Sep 2024 09:52:08 +0200 Subject: [PATCH] mousewheel_handle on wheel and not mousewheel (non standard event) + programmable mouse zoom key, (cherry picked from commit 59577a3c3da366d93c5f29bad35789d9319b2079) --- src/jsmind.js | 4 ++-- src/jsmind.option.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/jsmind.js b/src/jsmind.js index 3a67c69c..fb01ddfe 100644 --- a/src/jsmind.js +++ b/src/jsmind.js @@ -125,7 +125,7 @@ export default class jsMind { this.view.add_event(this, 'mousedown', this.mousedown_handle); this.view.add_event(this, 'click', this.click_handle); this.view.add_event(this, 'dblclick', this.dblclick_handle); - this.view.add_event(this, 'mousewheel', this.mousewheel_handle, true); + this.view.add_event(this, 'wheel', this.mousewheel_handle, true); } mousedown_handle(e) { if (!this.options.default_event_handle['enable_mousedown_handle']) { @@ -172,7 +172,7 @@ export default class jsMind { // Use [Ctrl] + Mousewheel, to zoom in/out. mousewheel_handle(e) { // Test if mousewheel option is enabled and Ctrl key is pressed. - if (!this.options.default_event_handle['enable_mousewheel_handle'] || !e.ctrlKey) { + if (!this.options.default_event_handle['enable_mousewheel_handle'] || (this.options.view.zoom.ctrlKey && !e.ctrlKey) || (this.options.view.zoom.shiftKey && !e.shiftKey) || (this.options.view.zoom.altKey && !e.altKey) || (this.options.view.zoom.metaKey && !e.metaKey)) { return; } var evt = e || event; diff --git a/src/jsmind.option.js b/src/jsmind.option.js index 05a5489e..8a76aa85 100644 --- a/src/jsmind.option.js +++ b/src/jsmind.option.js @@ -31,6 +31,10 @@ const default_options = { min: 0.5, max: 2.1, step: 0.1, + ctrlKey:true, + shiftKey:true, + altKey:false, + metaKey:false, }, custom_node_render: null, expander_style: 'char', // [char | number]