feat(studio): support middle-mouse panning in preview
What
Add middle-mouse panning to the Studio preview.
Why
This is the convenient and standard way to move around the preview in many visualization platforms.
How
- Handle preview panning through the shared preview surface instead of an overlay-specific path.
- Allow panning with the middle mouse button.
- Keep pan clamped to the real content surface, but add a small overscroll margin so it does not hard-stop at the content edge.
Test plan
How was this tested?
- [x] Unit tests added/updated
- [x] Manual testing performed
- [ ] Documentation updated (if applicable)
can you share a video testing it pls?
Sure, here is the white scene test video, use midlde-mouse to move around:
https://github.com/user-attachments/assets/ed6e597a-f3f1-4d23-8cec-f852c6f862be
Great feature @func25 ! Would you be open to adding trackpad two-finger panning support as well?
This would provide parity with tools like Remotion, where users can pan by dragging with two fingers on their trackpad. It's a common gesture on modern laptops and would make the preview navigation feel more complete.
Added, thanks for the idea (I saw your recommendation in the zoom in/out GitHub issue also)
Thank you so much for the fast response & commit @func25 ! It would be great if we can also include some of these small features/bug fixes in this PR too (or else I'll file a new issue instead, what do you think?):
-
Mouse wheel/trackpad zoom focuses into the center – Currently, mouse wheel/trackpad zoom always zooms into the center of the composition. It should zoom into the mouse pointer's location for intuitive navigation.
-
Reset zoom button – Currently, double-clicking on the canvas resets zoom (undocumented/hidden). I Suggest adding a visible, consistent 'Reset Zoom' button.
-
Canvas border expands inward when zooming – The gray border of the canvas grows thicker and eats into the preview canvas. This was previously reported (see PR #810) and is not fixed (PR was closed & not merged); the issue still happens in the current release and appears connected to CSS zoom vs. transform: scale.
Zoom screenshots:
When zoomed out:
When zoomed in:
Let's file a new issue. This PR should only handle panning :)
+1 to @func25 let's keep PRs focused and not bloat them to much @O1Anas. All great ideas though!