Skip to content

Implement custom scroll handling for ThreeJS scene container#676

Merged
timbastin merged 2 commits intomainfrom
fix-cube-scrolling
Mar 16, 2026
Merged

Implement custom scroll handling for ThreeJS scene container#676
timbastin merged 2 commits intomainfrom
fix-cube-scrolling

Conversation

@refoo0
Copy link
Copy Markdown
Member

@refoo0 refoo0 commented Mar 4, 2026

No description provided.

Signed-off-by: rafi <refaei.shikho@hotmail.com>
Copilot AI review requested due to automatic review settings March 4, 2026 11:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds custom wheel/scroll handling around the ThreeJS canvas so mouse-wheel input over the scene scrolls the page instead of being consumed by the ThreeJS controls/canvas.

Changes:

  • Wrapped the <Canvas /> in a container <div> with a ref.
  • Added a wheel event listener (capture, non-passive) to prevent default wheel behavior and forward scrolling to window.scrollBy.
Comments suppressed due to low confidence (2)

src/components/threejs/ThreeJSScene.tsx:108

  • window.scrollBy(0, e.deltaY) assumes deltaY is in pixels. WheelEvent.deltaMode can be LINE or PAGE on some devices/browsers, which will make scrolling far too slow/fast. Consider normalizing the scroll distance based on e.deltaMode before calling scrollBy.
    const handleWheel = (e: WheelEvent) => {
      e.stopPropagation();
      e.preventDefault();
      window.scrollBy(0, e.deltaY);
    };

src/components/threejs/ThreeJSScene.tsx:107

  • This handler calls preventDefault() for every wheel event, which will also block browser/page zoom gestures that are implemented as ctrl/trackpad-pinch + wheel (common accessibility workflow). Consider allowing default behavior when e.ctrlKey (and possibly e.metaKey) is pressed, or otherwise scoping the prevention so you don't disable zoom.
    const handleWheel = (e: WheelEvent) => {
      e.stopPropagation();
      e.preventDefault();
      window.scrollBy(0, e.deltaY);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@timbastin timbastin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just removing the camera controls component doesn't work? Or pointer-events: none

…ucture

Signed-off-by: rafi <refaei.shikho@hotmail.com>
@timbastin timbastin merged commit 01c6e76 into main Mar 16, 2026
11 checks passed
@timbastin timbastin deleted the fix-cube-scrolling branch March 16, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants