diff options
Diffstat (limited to 'src/app.js')
| -rw-r--r-- | src/app.js | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -695,9 +695,16 @@ function attachZoom(box, img, { wheel = true } = {}) { if (e.target.closest('.lightbox-x')) return; if (moved) { moved = false; e.stopImmediatePropagation(); e.preventDefault(); return; } }, true); + // The wheel. true: a turn zooms (the lightbox, a picture on its own). + // 'ctrl': ctrl+wheel zooms — a trackpad's pinch arrives in Chrome as + // exactly that — and a plain wheel pans the picture while it is zoomed; + // at 1× a plain wheel is left to whoever owns the box (the pager pages). if (wheel) box.addEventListener('wheel', (e) => { + const zoom = wheel !== 'ctrl' || e.ctrlKey || e.metaKey; + if (!zoom && s <= 1) return; e.preventDefault(); - zoomAt(s * Math.exp(-e.deltaY * 0.002), e.clientX, e.clientY); + if (zoom) zoomAt(s * Math.exp(-e.deltaY * (wheel === 'ctrl' ? 0.004 : 0.002)), e.clientX, e.clientY); + else { x -= e.deltaX; y -= e.deltaY; } clamp(); apply(false); }, { passive: false }); } |
