* Check browser support for pixelated image rendering * * @return {boolean}
()
| 12 | * @return {boolean} |
| 13 | */ |
| 14 | function supportsPixelatedImage() { |
| 15 | if(_supportsPixelated !== null) { // only run the feature detection once |
| 16 | return _supportsPixelated; |
| 17 | } |
| 18 | |
| 19 | _supportsPixelated = false; |
| 20 | |
| 21 | // @see https://github.com/plotly/plotly.js/issues/6604 |
| 22 | var unsupportedBrowser = Lib.isSafari() || Lib.isMacWKWebView() || Lib.isIOS(); |
| 23 | |
| 24 | if(window.navigator.userAgent && !unsupportedBrowser) { |
| 25 | var declarations = Array.from(constants.CSS_DECLARATIONS).reverse(); |
| 26 | |
| 27 | var supports = (window.CSS && window.CSS.supports) || window.supportsCSS; |
| 28 | if(typeof supports === 'function') { |
| 29 | _supportsPixelated = declarations.some(function(d) { |
| 30 | return supports.apply(null, d); |
| 31 | }); |
| 32 | } else { |
| 33 | var image3 = Drawing.tester.append('image') |
| 34 | .attr('style', constants.STYLE); |
| 35 | |
| 36 | var cStyles = window.getComputedStyle(image3.node()); |
| 37 | var imageRendering = cStyles.imageRendering; |
| 38 | |
| 39 | _supportsPixelated = declarations.some(function(d) { |
| 40 | var value = d[1]; |
| 41 | return ( |
| 42 | imageRendering === value || |
| 43 | imageRendering === value.toLowerCase() |
| 44 | ); |
| 45 | }); |
| 46 | |
| 47 | image3.remove(); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | return _supportsPixelated; |
| 52 | } |
| 53 | |
| 54 | module.exports = supportsPixelatedImage; |