Discuss Scratch

AHypnoman
Scratcher
1000+ posts

Zoom gesture triggers up/down arrows but doesn't preventDefault

Expected behaviour
Performing a zoom gesture on the stage should either:
1. Not zoom but instead trigger the up/down arrow key hat blocks
2. Zoom and not trigger the arrows
And should be consistent between a tablet and computer

Current behaviour
The gesture both zooms the page and triggers the hat blocks on a computer
The gesture is prevented entirely on a tablet so you can't zoom and it doesn't trigger the hat blocks

Steps to reproduce
1. Go here
2. Pinch to zoom on trackpad or hold ctrl-scroll (I think? I use trackpad)

Before zoom:



After zoom:



This has a really simple fix:

< stage element variable goes here >.addEventListener('wheel', event => {
   if (event.ctrlKey) {
      event.preventDefault();
      return
   }
}, {passive: false})

Last edited by AHypnoman (Aug. 31, 2024 23:14:40)

Powered by DjangoBB