Skip to content

Commit

Permalink
Add support for Firefox image downloading.
Browse files Browse the repository at this point in the history
  • Loading branch information
krunkosaurus committed Oct 21, 2016
1 parent af480a2 commit 15344ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dist/simg.min.js
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/simg.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
};

Simg.prototype = {

// Return SVG text.
toString: function(svg){
if (!svg){
Expand Down Expand Up @@ -120,9 +121,14 @@
}
this.toImg(function(img){
var a = document.createElement("a");
// Name of the file being downloaded.
a.download = filename + ".png";
a.href = img.getAttribute('src');
// Support for Firefox which requires inserting in dom.
a.style.display = 'none';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
});
}
};
Expand Down

0 comments on commit 15344ea

Please sign in to comment.