Skip to content

Commit 1b64db1

Browse files
authored
Merge pull request #6605 from lvlte/heatmap_safari_fix
Fix heatmap/image traces without zsmooth on Safari/iOS
2 parents 18b5097 + 67e611d commit 1b64db1

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

draftlogs/6605_fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix heatmap rendering on Safari when `zsmooth` is set to false [[#6605](https://github.com/plotly/plotly.js/pull/6605)], with thanks to @lvlte for the contribution!

src/lib/supports_pixelated_image.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,39 @@ function supportsPixelatedImage() {
1515
if(_supportsPixelated !== null) { // only run the feature detection once
1616
return _supportsPixelated;
1717
}
18-
if(Lib.isIE()) {
19-
_supportsPixelated = false;
20-
} 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) {
2125
var declarations = Array.from(constants.CSS_DECLARATIONS).reverse();
22-
var supports = window.CSS && window.CSS.supports || window.supportsCSS;
26+
27+
var supports = (window.CSS && window.CSS.supports) || window.supportsCSS;
2328
if(typeof supports === 'function') {
2429
_supportsPixelated = declarations.some(function(d) {
2530
return supports.apply(null, d);
2631
});
2732
} else {
28-
var image3 = Drawing.tester.append('image');
33+
var image3 = Drawing.tester.append('image')
34+
.attr('style', constants.STYLE);
35+
2936
var cStyles = window.getComputedStyle(image3.node());
30-
image3.attr('style', constants.STYLE);
37+
var imageRendering = cStyles.imageRendering;
38+
3139
_supportsPixelated = declarations.some(function(d) {
3240
var value = d[1];
33-
return cStyles.imageRendering === value ||
34-
cStyles.imageRendering === value.toLowerCase();
41+
return (
42+
imageRendering === value ||
43+
imageRendering === value.toLowerCase()
44+
);
3545
});
46+
3647
image3.remove();
3748
}
3849
}
50+
3951
return _supportsPixelated;
4052
}
4153

0 commit comments

Comments
 (0)