iPad IOS7 Page Jump Fix when keyboard closes

Sam Deering
Tweet

When you click on open space on the ipad the keyboard the page jumps down screen (to try and compensate for the space the keyboard used). This occurs when it wants to keep the input in view when your typing which makes sense and is useful but when you don’t use the keyboard close button it sometimes gets all confused and jumps the page…

To fix include:

HammerJS

Then add this:

 
        $('body').on("tap", function() {
            // alert('you touched me!');
            window.scrollTo(0, 0);
        });

Source:

Or if you want smoother scrolling include this:

 
        $('body').on("tap", function() {
            // alert('you touched me!');
            window.scrollTo(0);
        });

Source: http://flesler.com/jquery/scrollTo/

Free JavaScript: Novice to Ninja Sample

Get a free 32-page chapter of JavaScript: Novice to Ninja and receive updates on exclusive offers from SitePoint.

No Reader comments