(e: WheelEvent, editor: EditorWrapper)
| 215 | // Wheel events |
| 216 | |
| 217 | export function onWheelScroll(e: WheelEvent, editor: EditorWrapper) { |
| 218 | const isTargetingCanvas = e.target instanceof Element && e.target.closest("[data-viewport], [data-viewport-container], [data-node-graph]"); |
| 219 | |
| 220 | // Prevent zooming the entire page when using Ctrl + scroll wheel outside of the viewport |
| 221 | if (e.ctrlKey && !isTargetingCanvas) { |
| 222 | e.preventDefault(); |
| 223 | } |
| 224 | |
| 225 | // Redirect vertical scroll wheel movement into a horizontal scroll on a horizontally scrollable element |
| 226 | // There seems to be no possible way to properly employ the browser's smooth scrolling interpolation |
| 227 | const horizontalScrollableElement = e.target instanceof Element && !e.target.closest("[data-scrollable-y]") && e.target.closest("[data-scrollable-x]"); |
| 228 | if (horizontalScrollableElement && e.deltaY !== 0) { |
| 229 | horizontalScrollableElement.scrollTo(horizontalScrollableElement.scrollLeft + e.deltaY, 0); |
| 230 | return; |
| 231 | } |
| 232 | |
| 233 | if (isTargetingCanvas) { |
| 234 | e.preventDefault(); |
| 235 | const modifiers = makeKeyboardModifiersBitfield(e); |
| 236 | editor.onWheelScroll(e.clientX, e.clientY, e.buttons, e.deltaX, e.deltaY, e.deltaZ, modifiers); |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | // Receives a custom event dispatched when the user begins interactively editing with the text tool. |
| 241 | // We keep a copy of the text input element to check against when it's active for text entry. |
no test coverage detected