0

I call the following code:

$(document).scroll(function() {
    thedistance(); 
});

I want thedistance() to fire while the user is scrolling down the page on a iOS device, but instead of this happening, the function fires after the user has stopped scrolling - not during it.

I have heard that this is caused by the DOM Manipulation freezing while the user scrolls - as of 2016 is there any way around this problem?

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Dev1997
  • 657
  • 1
  • 5
  • 16
  • You can find what you're looking for over here: [jQuery live scroll event on mobile (work around)](http://stackoverflow.com/questions/18753367/jquery-live-scroll-event-on-mobile-work-around#18851679) – webFashion Apr 05 '16 at 11:41
  • @wigi I have tried those answers but have had no success. I need a solid solution if there is one in existence. – Dev1997 Apr 05 '16 at 11:55

1 Answers1

0

I have tried the below solution which works fine for me

<!DOCTYPE html>
<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
            <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
                <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
                <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
                <script>
                    $(document).on("pagecreate","#pageone",function(){
                                   $(document).on("scrollstart",function(){
                                                  alert("Started scrolling!");
                                                  });
                                   });
                    </script>
    </head>
    <body>
        <div data-role="page" id="pageone">

        </div> 
    </body>
</html>

also look out for this link this might be helpful
http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_event_scroll

Agent Chocks.
  • 1,312
  • 8
  • 19
  • 1
    Thanks for the reply - I tried `scrollstart` but on iPad it does not throw a alert until the user stops scrolling. I found a statement from W3Schools: "iOS devices freeze DOM manipulation during scrolls, which means that it is not possible to change something when the user scrolls. However, the jQuery team are working on a solution for this". Looks like it not possible for the time being. – Dev1997 Apr 05 '16 at 14:25