Showing
2 changed files
with
14 additions
and
1 deletions
... | @@ -59,11 +59,12 @@ | ... | @@ -59,11 +59,12 @@ |
59 | imageEditor.ui.resizeEditor(); | 59 | imageEditor.ui.resizeEditor(); |
60 | }; | 60 | }; |
61 | 61 | ||
62 | - console.log('imageeiasdfasdf', imageEditor) | 62 | + console.log("imageeiasdfasdf", imageEditor); |
63 | 63 | ||
64 | let gifGenerator; | 64 | let gifGenerator; |
65 | setTimeout(function () { | 65 | setTimeout(function () { |
66 | gifGenerator = new GifGenerator(imageEditor._graphics.getCanvas()); | 66 | gifGenerator = new GifGenerator(imageEditor._graphics.getCanvas()); |
67 | + gifGenerator.on("progress", (p) => console.log(p)); | ||
67 | }, 1000); | 68 | }, 1000); |
68 | function render() { | 69 | function render() { |
69 | gifGenerator.make().then( | 70 | gifGenerator.make().then( | ... | ... |
... | @@ -7,6 +7,7 @@ export class GifGenerator { | ... | @@ -7,6 +7,7 @@ export class GifGenerator { |
7 | this.canvas = canvas; | 7 | this.canvas = canvas; |
8 | this.width = canvas.getWidth(); | 8 | this.width = canvas.getWidth(); |
9 | this.height = canvas.getHeight(); | 9 | this.height = canvas.getHeight(); |
10 | + this.events = {}; | ||
10 | 11 | ||
11 | this._initializeGif(); | 12 | this._initializeGif(); |
12 | } | 13 | } |
... | @@ -19,6 +20,12 @@ export class GifGenerator { | ... | @@ -19,6 +20,12 @@ export class GifGenerator { |
19 | repeat: 0, | 20 | repeat: 0, |
20 | setQuality: 10, | 21 | setQuality: 10, |
21 | }); | 22 | }); |
23 | + | ||
24 | + Object.keys(this.events).map((event) => { | ||
25 | + this.events[event].map((callback) => { | ||
26 | + this.gif.on(event, callback); | ||
27 | + }); | ||
28 | + }); | ||
22 | } | 29 | } |
23 | 30 | ||
24 | _addFrame(delay = 0) { | 31 | _addFrame(delay = 0) { |
... | @@ -32,6 +39,11 @@ export class GifGenerator { | ... | @@ -32,6 +39,11 @@ export class GifGenerator { |
32 | this.gif.render(); | 39 | this.gif.render(); |
33 | } | 40 | } |
34 | 41 | ||
42 | + on(event, callback) { | ||
43 | + if (!this.events[event]) this.events[event] = []; | ||
44 | + this.events[event].push(callback); | ||
45 | + } | ||
46 | + | ||
35 | make() { | 47 | make() { |
36 | this._initializeGif(); | 48 | this._initializeGif(); |
37 | 49 | ... | ... |
-
Please register or login to post a comment