Now generating canvas image blob asynchonrously.
This commit is contained in:
parent
49175ebcff
commit
d81bb3fbf3
|
|
@ -98,19 +98,22 @@ function saveCanvas(canvas) {
|
|||
var c = document.getElementById(canvas);
|
||||
if (c == null) return;
|
||||
|
||||
// Create and click a link to the canvas data URL
|
||||
var a = document.createElement('a');
|
||||
a.href = c.toDataURL('image/png');
|
||||
a.style = 'display: none';
|
||||
a.download = canvas + ".png";
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
// Convert canvas to a data blob
|
||||
c.toBlob(function(blob) {
|
||||
// Create and click a link to the canvas data URL
|
||||
var a = document.createElement('a');
|
||||
a.href = window.URL.createObjectURL(blob);
|
||||
a.style = 'display: none';
|
||||
a.download = canvas + ".png";
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
|
||||
// Get rid of the canvas data URL
|
||||
setTimeout(function() {
|
||||
document.body.removeChild(a);
|
||||
window.URL.revokeObjectURL(a.href);
|
||||
}, 0);
|
||||
// Get rid of the canvas data URL
|
||||
setTimeout(function() {
|
||||
document.body.removeChild(a);
|
||||
window.URL.revokeObjectURL(a.href);
|
||||
}, 0);
|
||||
}, 'image/png');
|
||||
}
|
||||
|
||||
function zoomInOneStep() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue