오윤석

event 추가

......@@ -59,11 +59,12 @@
imageEditor.ui.resizeEditor();
};
console.log('imageeiasdfasdf', imageEditor)
console.log("imageeiasdfasdf", imageEditor);
let gifGenerator;
setTimeout(function () {
gifGenerator = new GifGenerator(imageEditor._graphics.getCanvas());
gifGenerator.on("progress", (p) => console.log(p));
}, 1000);
function render() {
gifGenerator.make().then(
......
......@@ -7,6 +7,7 @@ export class GifGenerator {
this.canvas = canvas;
this.width = canvas.getWidth();
this.height = canvas.getHeight();
this.events = {};
this._initializeGif();
}
......@@ -19,6 +20,12 @@ export class GifGenerator {
repeat: 0,
setQuality: 10,
});
Object.keys(this.events).map((event) => {
this.events[event].map((callback) => {
this.gif.on(event, callback);
});
});
}
_addFrame(delay = 0) {
......@@ -32,6 +39,11 @@ export class GifGenerator {
this.gif.render();
}
on(event, callback) {
if (!this.events[event]) this.events[event] = [];
this.events[event].push(callback);
}
make() {
this._initializeGif();
......