Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-webkit-overflow-scrolling polyfill or feature detection

Tags:

html

css

ios

mobile

-webkit-overflow-scrolling is new to iOS 5. I'm looking for a CSS polyfill or a method rather than user agent reading for detecting if this feature is available. Modernizer don't detect this.

like image 473
Mohsen Avatar asked Dec 23 '11 00:12

Mohsen


People also ask

Why polyfill is used?

A polyfill is a piece of code (usually JavaScript on the Web) used to provide modern functionality on older browsers that do not natively support it.

What is polyfill example?

For example, a polyfill could be used to mimic the functionality of an HTML Canvas element on Microsoft Internet Explorer 7 using a Silverlight plugin, or mimic support for CSS rem units, or text-shadow , or whatever you want.

What is polyfill and how do you use it?

Formally, "a polyfill is a shim for a browser API." Polyfills allow web developers to use an API regardless of whether or not it is supported by a browser, and usually with minimal overhead. Typically they first check if a browser supports an API, and use it if available, otherwise using their own implementation.

How does polyfill IO work?

Polyfill.io makes polyfilling support for newer JS features in older browsers super easy. It works via User-Agent sniffing to determine the browser being used, then loads the required polyfills. Explicitly define the features from the ECMAscript spec your code relies on.


1 Answers

Modernizr doesn't detect the property by default, but you can add your own test to it.

Just call this code anywhere:

Modernizr.addTest('overflowscrolling', function() {
    return Modernizr.testAllProps("overflowScrolling");
});

after the call, your body element will either have a overflowscrolling or a no-overflowscrolling class and you can check the support against Modernizr.overflowscrolling.

like image 159
fcurella Avatar answered Sep 24 '22 15:09

fcurella