Skip to content
Snippets Groups Projects
Commit 4c2cb5ff authored by mathias.chouet's avatar mathias.chouet
Browse files

Add Edge polyfill for toBlob method

parent d828a1ca
No related branches found
No related tags found
No related merge requests found
......@@ -78,3 +78,21 @@ import "zone.js/dist/zone"; // Included with Angular CLI.
// Requis pour Buffer dans jalhyd (!?)
(window as any).global = window;
global.Buffer = global.Buffer || require("buffer").Buffer;
// Edge polyfill for canvas.toBlob method
if (!HTMLCanvasElement.prototype.toBlob) {
Object.defineProperty(HTMLCanvasElement.prototype, "toBlob", {
value: function (callback, type, quality) {
const dataURL = this.toDataURL(type, quality).split(",")[1];
setTimeout(function() {
const binStr = atob( dataURL ),
len = binStr.length,
arr = new Uint8Array(len);
for (let i = 0; i < len; i++ ) {
arr[i] = binStr.charCodeAt(i);
}
callback( new Blob( [arr], {type: type || "image/png"} ) );
});
}
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment