Skip to content

Commit fe7bbef

Browse files
committed
Add option to control zoom invertion
1 parent 040c3ea commit fe7bbef

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

web/libs/editor/src/core/settings/editorsettings.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,14 @@ export default {
8484
onChangeEvent: "toggleSmoothing",
8585
defaultValue: true,
8686
},
87+
invertedZoom: {
88+
newUI: {
89+
tags: "Image Tag",
90+
title: "Invert zoom direction",
91+
description: "Invert the direction of scroll-to-zoom",
92+
},
93+
description: "Enable inverted zoom direction",
94+
onChangeEvent: "toggleInvertedZoom",
95+
defaultValue: false,
96+
},
8797
};

web/libs/editor/src/stores/SettingsStore.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ const SettingsModel = types
7272
isDestroying: types.optional(types.boolean, false),
7373

7474
videoDrawOutside: types.optional(types.boolean, false),
75+
76+
invertedZoom: types.optional(types.boolean, false),
7577
})
7678
.views((self) => ({
7779
get annotation() {
@@ -231,6 +233,14 @@ const SettingsModel = types
231233
self.enableSmoothing = value;
232234
},
233235

236+
toggleInvertedZoom() {
237+
self.invertedZoom = !self.invertedZoom;
238+
},
239+
240+
setInvertedZoom(value) {
241+
self.invertedZoom = value;
242+
},
243+
234244
setVideoHopSize(value) {
235245
self.videoHopSize = value;
236246
},

web/libs/editor/src/tags/object/Image/Image.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,12 +931,14 @@ const Model = types
931931
},
932932

933933
getInertialZoom(val) {
934+
const invert = getRoot(self).settings.invertedZoom ? 1 : -1;
935+
934936
// Invert the delta value so that:
935937
// - Pinch out (positive deltaY) zooms in
936938
// - Pinch in (negative deltaY) zooms out
937939
// - Scroll up (positive deltaY) zooms in
938940
// - Scroll down (negative deltaY) zooms out
939-
const invertedVal = -val;
941+
const invertedVal = val * invert;
940942

941943
// Calculate the zoom change using exponential formula
942944
// This provides smooth zooming for both mouse wheel and trackpad pinch

0 commit comments

Comments
 (0)