Posted By

envane21 on 09/07/15


Tagged

scroll mobile up


Versions (?)

Automatic Scroll Up


 / Published in: jQuery
 

Used to automatically scroll up the page so that it is focused on user entry (mobile devices)

  1. var clicked = false;
  2.  
  3. $(document).on('click', '#msisdn-input' , function(e){
  4. e.preventDefault();
  5. if(clicked===false){
  6. window.scrollTo(0,1);
  7. clicked = true;
  8. }
  9. setTimeout(function(){
  10. $('#scroll').css('float','left');
  11. scrollSize = $('.submit-button').offset().top + $('.submit-button').outerHeight()+5;
  12. console.log(scrollSize);
  13. screenSize = $(window).height();
  14. result = (scrollSize-screenSize);
  15. if(result>0){
  16. $('html, body').animate({scrollTop:result},'200');
  17. }
  18. },700);
  19. });

Report this snippet  

You need to login to post a comment.