Disable Scrolling scrolls to top when image is clicked.
See original GitHub issueWhy does clicking the image to open the modal scrolls the page to the top when disableScrolling
is true?
To produce the following bug, go to Lightbox Examples, open the console, and enter the following.
lightbox.option({ disableScrolling: true });
Then before clicking an image, scroll so that you’re not at the top of the page but you should still see the image (so you could click it tho).
After clicking, you can see that the modal opens but the page scrolls up, leaving the modal down there! Are there other things that I should do when implementing disableScrolling
?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:14 (2 by maintainers)
Top Results From Across the Web
How do I stop a web page from scrolling to the top when a link ...
This way when the link is clicked the page won't scroll to top. This is cleaner than using href="#" and then preventing the...
Read more >How to disable scrolling temporarily using JavaScript
The current scroll position from the top is found by using the window.pageYOffset and the document.documentElement.scrollTop values.
Read more >How To Create a Scroll Back To Top Button - W3Schools
This example demonstrates how to create a "scroll to top" button that becomes visible when the user starts to scroll the page. Try...
Read more >overscroll-behavior - CSS: Cascading Style Sheets | MDN
The overscroll-behavior CSS property sets what a browser does when reaching the boundary of a scrolling area.
Read more >Prevent Page Scrolling When a Modal is Open | CSS-Tricks
If we know the top of the scroll location and add it to our CSS, then the body will not scroll back to...
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
It looks like the class “.lb-disable-scrolling” is the issue. I commented out the “position: fixed;” attribute and it seems to be working fine now on desktop.
The author put a note in here though saying position: fixed is required for iOS. I am going to add this to the css to see if I can make it work on iOS as well (haven’t tested yet):
Just Add below line to your lightbox-plus-jquery.min.js file .
lightbox.option({ disableScrolling: true });