Skip to content

Commit 3fd8f9a

Browse files
committed
refactor: remove factor, fixed #308
1 parent 12a7cec commit 3fd8f9a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/plugin/keypress.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ const handlePrevNext = function (mei: MindElixirInstance, direction: 'previous'
5555
mei.selectNode(sibling.firstChild.firstChild)
5656
}
5757
}
58-
const handleZoom = function (mei: MindElixirInstance, direction: 'in' | 'out', factor = 1) {
58+
const handleZoom = function (mei: MindElixirInstance, direction: 'in' | 'out') {
5959
switch (direction) {
6060
case 'in':
61-
if (mei.scaleVal * factor > 1.6) return
61+
if (mei.scaleVal > 1.6) return
6262
mei.scale((mei.scaleVal += 0.2))
6363
break
6464
case 'out':
65-
if (mei.scaleVal * factor < 0.6) return
65+
if (mei.scaleVal < 0.6) return
6666
mei.scale((mei.scaleVal -= 0.2))
6767
}
6868
}
@@ -187,9 +187,8 @@ export default function (mind: MindElixirInstance) {
187187
mind.map.onwheel = e => {
188188
if (e.ctrlKey || e.metaKey) {
189189
e.preventDefault()
190-
const factor = Math.abs(e.deltaY / 100) // this can be tweaked
191-
if (e.deltaY < 0) handleZoom(mind, 'in', factor)
192-
else if (mind.scaleVal - 0.2 > 0) handleZoom(mind, 'out', factor)
190+
if (e.deltaY < 0) handleZoom(mind, 'in')
191+
else if (mind.scaleVal - 0.2 > 0) handleZoom(mind, 'out')
193192
e.stopPropagation()
194193
}
195194
}

0 commit comments

Comments
 (0)