Last active
December 6, 2019 03:31
-
-
Save radiovisual/8870e0ce297037c13974 to your computer and use it in GitHub Desktop.
Open your Mobile Menus and Disable Background Scrolling
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If the background-image is resizing on initial scroll, I assume the element with that background must have a dynamic height, generated using either vw/vh in the CSS or JS/jQ script. I ran into this same problem, and I found what I believe to be the correct method in resolving this issue (at least until mobile browsers provide their own workaround).
Using a simple jQuery function, you can store the window's width on page load, and use that to restrict the container's resizing function to viewport sizes wider than the desktop breakpoint (992px+) and narrower viewports so long as the viewport width changes, not just the height. This way, on mobile and tablet devices, when you scroll, there is only a vertical viewport resize, so the resize function is not triggered.
CodePen: https://codepen.io/brandonmcconnell/pen/jayYbB