Skip to content

Commit

Permalink
pinch-to-zoom
Browse files Browse the repository at this point in the history
fixes #204
An unintended consequence is that wheel-zooming with the ctrlKey pressed goes 10x faster, but it's rather agreeable.
  • Loading branch information
Fil committed Jul 13, 2020
1 parent 87781b6 commit 4d2a5f1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/zoom.js
Expand Up @@ -9,8 +9,9 @@ import {Transform, identity} from "./transform.js";
import noevent, {nopropagation} from "./noevent.js";

// Ignore right-click, since that should open the context menu.
// except for pinch-to-zoom, which is sent as a wheel+ctrlKey event
function defaultFilter(event) {
return !event.ctrlKey && !event.button;
return (!event.ctrlKey || event.type === 'wheel') && !event.button;
}

function defaultExtent() {
Expand All @@ -31,7 +32,7 @@ function defaultTransform() {
}

function defaultWheelDelta(event) {
return -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002);
return -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002) * (event.ctrlKey ? 10 : 1);
}

function defaultTouchable() {
Expand Down

0 comments on commit 4d2a5f1

Please sign in to comment.