4

I want to detect if a browser supports onscroll immediately?.. The problem is that older IOS versions of IOS support onscroll, but it gets triggered at the end of the scrolling. However I can't think of a way to detect this?

Jason
  • 11,263
  • 21
  • 87
  • 181
jon
  • 1,429
  • 1
  • 23
  • 40
  • Since you tagged this question with jquery, is element.on("scroll", function(){}) not working? – kasper Taeymans Feb 06 '15 at 09:46
  • @kasperTaeymans — How would that test to tell the difference between the two implementations of `scroll` that the question describes? That won't even tell you if it is supported *at all* until the event is fired. – Quentin Feb 06 '15 at 09:50
  • it doesn't, but why is this question tagged with jquery? – kasper Taeymans Feb 06 '15 at 09:52

3 Answers3

1

Since you are not trying to detect wether the onscroll is supported or not but you try to check its implementation I would say that agent sniffing is the best way (although agent sniffing is generally bad thing).

strah
  • 6,702
  • 4
  • 33
  • 45
1

Older verions then IOS8 pauses "DOM painting" while the scroll event is fired. An excellent article about the onscroll differences between IOS versions can be found here:

http://developer.telerik.com/featured/scroll-event-change-ios-8-big-deal/

http://ejohn.org/blog/learning-from-twitter/

Since IOS version 8 the onscroll will fire continuously. You could check IOS version with javascript.

function iOSversion() {
  if (/iP(hone|od|ad)/.test(navigator.platform)) {
    var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
    return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
  }
}

version = iOSversion();

if (version[0] > 7) {
  alert('Continuous scrolling is working!');
}
kasper Taeymans
  • 6,950
  • 5
  • 32
  • 51
0

You don't specify which versions of iOS that have this kind of scroll event behavior, so I would suggest user agent string processing on page load.

http://www.webapps-online.com/online-tools/user-agent-strings/dv/operatingsystem51849/ios has a good source of iOS 7 and 8 user agent strings. If none match, then the application can go to another set of defined behavior for scrolling.

Jason
  • 11,263
  • 21
  • 87
  • 181