Skip to content

Commit 3fca377

Browse files
painfully work through more IE bugs with snapshot
1 parent 41c3126 commit 3fca377

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

src/components/modebar/buttons.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ modeBarButtons.toImage = {
5353

5454
Lib.notifier('Taking snapshot - this may take a few seconds', 'long');
5555

56-
if(Lib.isIE()){
56+
if(Lib.isIE()) {
5757
Lib.notifier('IE only supports svg. Changing format to svg.', 'long');
5858
format = 'svg';
5959
}
6060

61-
downloadImage(gd, {'format':format})
61+
downloadImage(gd, {'format': format})
6262
.then(function(filename) {
6363
Lib.notifier('Snapshot succeeded - ' + filename, 'long');
6464
})
6565
.catch(function() {
66-
Lib.notifier('Sorry there was a problem downloading your snapshot', 'long');
66+
Lib.notifier('Sorry there was a problem downloading your snapshot!', 'long');
6767
});
6868
}
6969
};

src/plot_api/to_image.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ function toImage(gd, opts) {
3737
if(isNumeric(size) && size > 1) {
3838
return true;
3939
}
40+
41+
return false;
4042
};
4143

4244
if(!isSizeGood(opts.width) || !isSizeGood(opts.height)) {
@@ -80,7 +82,7 @@ function toImage(gd, opts) {
8082
// compatibility
8183
promise: true
8284
}).then(function(url) {
83-
if(clonedGd) clonedGd.remove();
85+
if(clonedGd) document.body.removeChild(clonedGd);
8486
resolve(url);
8587
}).catch(function(err) {
8688
reject(err);

src/snapshot/filesaver.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ var fileSaver = function(url, name) {
5252
}
5353

5454
// IE 10+ (native saveAs)
55-
if(typeof navigator !== 'undefined' && navigator.msSaveOrOpenBlob) {
56-
navigator.msSaveOrOpenBlob(url, name);
55+
if(typeof navigator !== 'undefined' && navigator.msSaveBlob) {
56+
navigator.msSaveBlob(new Blob([url]), name);
5757
resolve(name);
5858
}
5959

src/snapshot/svgtoimg.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ function svgToImg(opts) {
5656
img.onload = function() {
5757
var imgData;
5858

59-
ctx.drawImage(img, 0, 0);
59+
// don't need to draw to canvas if svg
60+
// save some time and also avoid failure on IE
61+
if(format !== 'svg') {
62+
ctx.drawImage(img, 0, 0);
63+
}
6064

6165
switch(format) {
6266
case 'jpeg':

src/snapshot/toimage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function toImage(gd, opts) {
5757
});
5858

5959
ev.clean = function() {
60-
if(clonedGd) clonedGd.remove();
60+
if(clonedGd) document.body.removeChild(clonedGd);
6161
};
6262

6363
}, delay);

0 commit comments

Comments
 (0)