Posted By

cerxx on 03/24/19


Tagged

adaptive js-hacks


Versions (?)

jQuery scrollTop not working on Mobile Devices (iPhone, iPad, Android Phones)


 / Published in: JavaScript
 

URL: http://blog.jonathanargentiero.com/jquery-scrolltop-not-working-on-mobile-devices-iphone-ipad-android-phones/

Mobile devices often doesn’t scroll the page moving the or elements, they move the viewport as far as i understood, we don’t really care, what we care is how make things shine again

  1. var destination = $('#anchor').offset().top;
  2. if (navigator.userAgent.match(/(iPod|iPhone|iPad|Android)/)) {
  3. $(window).scrollTop(destination);
  4. } else {
  5. $('html,body').animate({
  6. scrollTop: destination - 60,
  7. scrollLeft: 0
  8. }, 400, function(){
  9. $('html,body').clearQueue();
  10. });
  11. }

Report this snippet  

You need to login to post a comment.