I just want to block some scrolling on my mobile.

Asked 2 years ago, Updated 2 years ago, 51 views

<body><!-- with scroll -->
    <div style="position: fixed"></div><!-- With and Without scrolling -->
</body>

For example, when I'm like this, If div does not scroll or if you continue to move the screen up or down when the scroll arrives at each end, the scroll in the body part moves, and I want to stop the scroll in the body part.

jquery javascript

2022-09-22 13:47

1 Answers

The point is this.

Register the Scroll Event Listener Prevent browser default scrolling The value received from the event Manually move the scroll position.

(Hmm...) I've tried this and that, but this is the only way left.)

https://codepen.io/digda/pen/xeVRKR

I wrote it based on jquery There is a separate corresponding code for desktop/mobile.

The scroll inertia that mobile provides by default disappears. To apply inertia, we need to implement it ourselves or use a library that implements custom scroll inertia.

Please modify it according to the characteristics of the page you are configuring.


2022-09-22 13:47

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.