Prevent UI pinch-to-zoom while keeping canvas zoomable

- Add touch-action CSS to prevent pinch-zoom on UI elements
- Apply touch-action: pan-x pan-y to html, body, and editor
- Apply touch-action: none to canvas for custom gestures
- Add JavaScript prevention for touchpad pinch on non-canvas areas
- Block Ctrl+wheel events outside the workspace chart
pull/5312/head
Dimitrie Hoekstra 2025-09-29 18:49:07 +02:00 committed by Nick O'Leary
parent 3e2fb85821
commit bf73261ecb
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
3 changed files with 11 additions and 1 deletions

View File

@ -757,6 +757,13 @@ RED.view = (function() {
var wheelEventContinuityThreshold = 100; // Events within 100ms are same gesture
var gestureEndThreshold = 500; // 500ms+ gap means gesture ended
// Prevent browser zoom on non-canvas areas
document.addEventListener("wheel", function(e) {
if (e.ctrlKey && !e.target.closest('#red-ui-workspace-chart')) {
e.preventDefault();
}
}, { passive: false });
chart.on("wheel", function(evt) {
// ctrlKey is set during pinch gestures on trackpads
if (evt.ctrlKey || evt.altKey || spacebarPressed) {

View File

@ -17,8 +17,9 @@
**/
body {
html, body {
overflow: hidden;
touch-action: pan-x pan-y;
}
.red-ui-editor {
@ -29,6 +30,7 @@ body {
background: var(--red-ui-primary-background);
color: var(--red-ui-primary-text-color);
line-height: 20px;
touch-action: pan-x pan-y;
}
#red-ui-editor {

View File

@ -37,6 +37,7 @@
right:0px;
box-sizing:border-box;
transition: right 0.2s ease;
touch-action: none;
&:focus {
outline: none;
}