Disable Scrolling on Mobile and Desktop with a Click Event

When making a push menu (a menu which opens from the side) it is desirable for the screen to be locked in place both on mobile and desktop since you wouldn’t want users to scroll the site whilst viewing the menu.

To overcome this problem I made a small snippet that allows you to disable scrolling with some class manipulations and event listeners.

See the Pen Push Menu by Matthew Horne (@horne3754sg) on CodePen.

In Category: JavaScript