From 50ae3b6719f8eb7418fbb83dd4e39d1b7feb967a Mon Sep 17 00:00:00 2001 From: shimwell Date: Wed, 4 Nov 2026 22:34:39 +0100 Subject: [PATCH] Fix slow vertical rotation in the Sphinx viewer on tall pages The interactor was bound to document.body and vtk.js scales mouse positions by the size of the bound element, so on pages where the body is taller than the window vertical drags were shrunk. Bind to an object that listens on the body but reports the canvas size. --- cadquery/cq_directive.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cadquery/cq_directive.py b/cadquery/cq_directive.py index 3749c379f..624a5b5e8 100644 --- a/cadquery/cq_directive.py +++ b/cadquery/cq_directive.py @@ -106,8 +106,15 @@ document.addEventListener('scroll', recomputeViewports); +// listens on the body but reports the canvas size, which vtk.js uses to convert mouse positions +const eventContainer = { + addEventListener: (...args) => document.body.addEventListener(...args), + removeEventListener: (...args) => document.body.removeEventListener(...args), + getBoundingClientRect: () => openglRenderWindow.getCanvas().getBoundingClientRect(), +}; + function enterCurrentRenderer(e) { - interactor.bindEvents(document.body); + interactor.bindEvents(eventContainer); interact_style.setEnabled(true); interactor.setCurrentRenderer(RENDERERS[e.target.id]); }