jon
jon

Reputation: 1581

How to detect if browser supports js onscroll.. immediately

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?

Upvotes: 4

Views: 162

Answers (3)

kasper Taeymans
kasper Taeymans

Reputation: 7026

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!');
}

Upvotes: 1

Jason
Jason

Reputation: 11363

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.

Upvotes: 0

strah
strah

Reputation: 6722

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).

Upvotes: 1

Related Questions