How to enable the ability to scroll a page with Matter.js?
See original GitHub issueI want to enable scrolling in a page that contains a Matter.js canvas. I have found and tried a few solutions such as removingEventListener without success. I created a post on StackOverflow but no luck with answers. Therefore I decided to come directly to the source of knowledge.
How can I enable page scrolling in a page with Matter.js? Thank you in advance.
Here’s the Codepen and the post.
// Why is this not working?
mouseConstraint.mouse.element.removeEventListener(
"mousewheel",
mouseConstraint.mouse.mousewheel
);
mouseConstraint.mouse.element.removeEventListener(
"DOMMouseScroll",
mouseConstraint.mouse.mousewheel
);
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Prevent scroll on bodies (Matter.js) - javascript - Stack Overflow
This makes it possible for the user to scroll through the page and still being able to interact with the scene by clicking...
Read more >Physics-Based Background Scroll Effects - Coder's Block
This article will show you how to create nifty physics-based background scroll effects for your web pages. We'll be using Matter.js, ...
Read more >1 How to load matter.js into p5 web editor p5.js - YouTube
Learn 2 ways to load matter. js into the p5 web editor:#1. Download matter. js & upload it into the p5 web editor#2....
Read more >Getting Started With Matter.js: The Body Module - Code
In this tutorial, you will learn about all these methods and properties and how to use them properly. Scaling, Rotating, and Translating a...
Read more >How to get started with matter.js and Physics in JavaScript
If you want you can check some of the demo's. On the sidebar, click 'Source Code' which should lead you to the GitHub...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The answer is provided by Xander Gottlieb in a blog post along with many other tips Matter.js— The Missing Tutorial.
By default,
MouseConstraint
captures scroll events. The following snippet fixes it.I’m still unable to solve the problem in touch screen devices.