Skip to content

Commit 67e611d

Browse files
committed
fix zsmooth false rendering : check useragent, improve readabiity
1 parent 80503a5 commit 67e611d

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/lib/supports_pixelated_image.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,39 @@ function supportsPixelatedImage() {
1515
if(_supportsPixelated !== null) { // only run the feature detection once
1616
return _supportsPixelated;
1717
}
18-
if(Lib.isIE() || Lib.isSafari() || Lib.isIOS()) {
19-
// NB. Safari passes the test below but the final rendering is not pixelated
20-
_supportsPixelated = false;
21-
} else {
18+
19+
_supportsPixelated = false;
20+
21+
// @see https://github.com/plotly/plotly.js/issues/6604
22+
var unsupportedBrowser = Lib.isIE() || Lib.isSafari() || Lib.isIOS();
23+
24+
if(window.navigator.userAgent && !unsupportedBrowser) {
2225
var declarations = Array.from(constants.CSS_DECLARATIONS).reverse();
23-
var supports = window.CSS && window.CSS.supports || window.supportsCSS;
26+
27+
var supports = (window.CSS && window.CSS.supports) || window.supportsCSS;
2428
if(typeof supports === 'function') {
2529
_supportsPixelated = declarations.some(function(d) {
2630
return supports.apply(null, d);
2731
});
2832
} else {
29-
var image3 = Drawing.tester.append('image');
33+
var image3 = Drawing.tester.append('image')
34+
.attr('style', constants.STYLE);
35+
3036
var cStyles = window.getComputedStyle(image3.node());
31-
image3.attr('style', constants.STYLE);
37+
var imageRendering = cStyles.imageRendering;
38+
3239
_supportsPixelated = declarations.some(function(d) {
3340
var value = d[1];
34-
return cStyles.imageRendering === value ||
35-
cStyles.imageRendering === value.toLowerCase();
41+
return (
42+
imageRendering === value ||
43+
imageRendering === value.toLowerCase()
44+
);
3645
});
46+
3747
image3.remove();
3848
}
3949
}
50+
4051
return _supportsPixelated;
4152
}
4253

0 commit comments

Comments
 (0)