Enable/Disable Scrolling in iPhone/iPad’s Safari Browser

Enable/Disable Scrolling in iPhone/iPad’s Safari Browser

Hey there! Today when we were testing our Showcase Articles on an iPhone – we noticed that when we launched the full-screen mode the user could still scroll down and view the content below the visible height.

We were looking for a way to prevent the user from scrolling once viewing the Showcase Item in Full-Screen mode. So here is the code we used.

document.ontouchmove = function(e){ e.preventDefault(); }

A touchmove event is usually triggered when a finger already placed on the screen of the iPhone/iPad is moved across the screen. What we did was prevent the default behavior which was scrolling!

Now, this gave rise to another situation. How do we enable scrolling once the user closes the full-screen view? After a little research we finally figured out the solution ourselves as below

document.ontouchmove = function(e){ return true; }

This just returns true and give a go-ahead to whatsoever happens when a touchmove event is triggered!

Filed under: Blog, iOS, Javascript, Web Design

Comments are closed.