Skip to content

Commit 5ecf03f

Browse files
hizzgdevsam
and
sam
authored
[Features] Scenari mouse zoom (#643)
* mousewheel_handle on wheel and not mousewheel (non standard event) + programmable mouse zoom key, (cherry picked from commit 59577a3) * use composed keycode instead of 4 different keys * code format * fix ut * code format --------- Co-authored-by: sam <[email protected]>
1 parent 811a9c5 commit 5ecf03f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/jsmind.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export default class jsMind {
125125
this.view.add_event(this, 'mousedown', this.mousedown_handle);
126126
this.view.add_event(this, 'click', this.click_handle);
127127
this.view.add_event(this, 'dblclick', this.dblclick_handle);
128-
this.view.add_event(this, 'mousewheel', this.mousewheel_handle, true);
128+
this.view.add_event(this, 'wheel', this.mousewheel_handle, true);
129129
}
130130
mousedown_handle(e) {
131131
if (!this.options.default_event_handle['enable_mousedown_handle']) {
@@ -172,7 +172,11 @@ export default class jsMind {
172172
// Use [Ctrl] + Mousewheel, to zoom in/out.
173173
mousewheel_handle(e) {
174174
// Test if mousewheel option is enabled and Ctrl key is pressed.
175-
if (!this.options.default_event_handle['enable_mousewheel_handle'] || !e.ctrlKey) {
175+
var kc = (e.metaKey << 13) + (e.ctrlKey << 12) + (e.altKey << 11) + (e.shiftKey << 10);
176+
if (
177+
!this.options.default_event_handle['enable_mousewheel_handle'] ||
178+
this.options.view.zoom.mask_key !== kc
179+
) {
176180
return;
177181
}
178182
var evt = e || event;

src/jsmind.option.js

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const default_options = {
3131
min: 0.5,
3232
max: 2.1,
3333
step: 0.1,
34+
mask_key: 4096,
3435
},
3536
custom_node_render: null,
3637
expander_style: 'char', // [char | number]

0 commit comments

Comments
 (0)