├── LICENSE.txt ├── README.md ├── bower.json ├── examples ├── animating-natively-vs-jquery │ ├── jquery.html │ └── natively.html ├── assets │ ├── browserlogos │ │ ├── chrome.png │ │ ├── firefox.png │ │ ├── ie.png │ │ ├── ios.png │ │ ├── opera.png │ │ └── safari.png │ ├── common.css │ ├── picture-small.jpg │ └── picture.jpg ├── declarative-vs-programmatic │ ├── declarative.html │ ├── programmatic-via-jquery.html │ └── programmatic.html ├── index.html ├── loading-via-vanillajs-vs-contentloaded-vs-jquery │ ├── contentloaded.html │ ├── jquery.html │ └── vanilla.html ├── static-vs-animated │ ├── animated.html │ └── static.html └── stylesheet-embedded-vs-external │ ├── embedded.html │ ├── external.html │ └── filters.css └── lib ├── contentloaded.js ├── css-filters-polyfill-parser.js ├── css-filters-polyfill.js ├── cssParser.js └── htc ├── .htaccess ├── brightness.htc ├── drop-shadow.htc └── sepia.htc /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Christian Schepp Schaefer 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Polyfilter - a CSS Filters Polyfill 2 | =================================== 3 | 4 | This polyfill takes the official CSS Filter Effects syntax, which spec you can find over [here](http://www.w3.org/TR/filter-effects/#FilterProperty) and translates it to the different equivalent techniques that the browsers know for those effects: 5 | 6 | * Prefixing for WebKit/Blink-based browsers 7 | * Translating into SVG-filters for Firefox 8 | * Translating into DirectX-filters for IE 6-9 9 | 10 | For instance, this allows you to assign a property like 11 | 12 | `filter: blur(10px);` 13 | 14 | in your stylesheets and the polyfill will take care that it works in as many browsers as possible. 15 | 16 | ## Supported Filters 17 | 18 | * grayscale* 19 | * sepia* 20 | * blur 21 | * invert* 22 | * brightness 23 | * drop-shadow 24 | 25 | Have a look at [this overview](http://schepp.github.io/CSS-Filters-Polyfill/examples/static-vs-animated/static.html). 26 | 27 | \* _the IEs only support 0% or 100% values_ 28 | 29 | ## Supported Browsers 30 | 31 | Currently the polyfill is able to support 32 | 33 | * Chrome 20+ (brightness filter 28+), 34 | * Opera 15+ 35 | * Safari 6+, 36 | * Yandex 1+, 37 | * Firefox 4+, 38 | * IE 6 - 9 on desktop (IE 6 & 7 slightly degraded), 39 | 40 | and 41 | 42 | * iOS 6+ Safari/Chrome/Webview 43 | * Chrome 28+ on Android, 44 | * Opera Mobile 14+, 45 | * Blackberry Browser 10+, 46 | * Firefox 4+ on Mobile, 47 | * IE on Windows Phone 7, which just supports grayscale. 48 | 49 | Also have a look at [http://caniuse.com/css-filters](http://caniuse.com/css-filters) 50 | 51 | ## Not supported Browsers 52 | 53 | * IE 10+, 54 | * older Presto-based Operas, 55 | * Opera Mini, 56 | * Android browser 57 | 58 | ### A word regarding IE 10+ 59 | 60 | Why is IE 6 - 9 supported, but not IE 10 or higher? Well, since Microsoft decided to switch sides and to now follow standards, they killed their old proprietary filters beginning with IE 10 which I rely on for emulation. 61 | 62 | Altough they did introduce SVG filters sadly those are limited to a usage inside SVGs. They cannot be applied to HTML-elements. 63 | 64 | Even triggering legacy mode does not help any more. So this is why we are left at the end with no hook/support at all in IE10+ :( 65 | 66 | ### And what about those Presto-based Opera? 67 | 68 | Older Operas with Presto engine are not supported, as they offer none of the hooks I used. 69 | 70 | ## Setup 71 | 72 | First create a ` 78 | ``` 79 | 80 | This is important both for the old IEs and the web worker script. 81 | 82 | Should you not want the document stylesheets to not get automatically parsed, like when your plan is to apply filters only via JavaScript, then you can additionally set a `polyfilter_skip_stylesheets` switch: 83 | 84 | ```html 85 | 89 | ``` 90 | 91 | Then you link `cssParser.js` and `css-filters-polyfill.js` from the polyfill library. 92 | 93 | ```html 94 | 95 | 96 | ``` 97 | 98 | In an ideal world you should minify and concatenate both of them together with your other JavaScript. If you don't want your page to get blocked by script-loading you put the scripts way down before the closing `
17 |#filter1 {filter: grayscale(1);}
`. This might lead to some flickering of the filter effects during loading. If you can't live with the short flickering, put the scripts in the `
` of the page. Then it'll be gone, but your page will load slower. You decide. 99 | 100 | ## Usage 101 | 102 | ### Declarative assignment 103 | 104 | This polyfill supports filter declarations in embedded (` 14 | 15 | 16 |
39 |