MCPcopy Create free account
hub / github.com/plotly/plotly.js / supportsPixelatedImage

Function supportsPixelatedImage

src/lib/supports_pixelated_image.js:14–52  ·  view source on GitHub ↗

* Check browser support for pixelated image rendering * * @return {boolean}

()

Source from the content-addressed store, hash-verified

12 * @return {boolean}
13 */
14function 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
54module.exports = supportsPixelatedImage;

Callers 2

plot.jsFile · 0.85
plot.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…