/ Published in: jQuery
Used to automatically scroll up the page so that it is focused on user entry (mobile devices)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var clicked = false; $(document).on('click', '#msisdn-input' , function(e){ e.preventDefault(); if(clicked===false){ window.scrollTo(0,1); clicked = true; } setTimeout(function(){ $('#scroll').css('float','left'); scrollSize = $('.submit-button').offset().top + $('.submit-button').outerHeight()+5; console.log(scrollSize); screenSize = $(window).height(); result = (scrollSize-screenSize); if(result>0){ $('html, body').animate({scrollTop:result},'200'); } },700); });