Showing
1 changed file
with
25 additions
and
4 deletions
... | @@ -34,17 +34,38 @@ class GifGenerator { | ... | @@ -34,17 +34,38 @@ class GifGenerator { |
34 | fabricObjs.map((fabricObj) => { | 34 | fabricObjs.map((fabricObj) => { |
35 | if (fabricObj instanceof fabric.Path) { | 35 | if (fabricObj instanceof fabric.Path) { |
36 | objs.push(new Component.Brush(fabricObj)); | 36 | objs.push(new Component.Brush(fabricObj)); |
37 | + this.canvas.remove(fabricObj); | ||
37 | } else if (fabricObj.text !== undefined) { | 38 | } else if (fabricObj.text !== undefined) { |
38 | objs.push(new Component.Text(fabricObj)); | 39 | objs.push(new Component.Text(fabricObj)); |
40 | + this.canvas.remove(fabricObj); | ||
39 | } | 41 | } |
40 | }); | 42 | }); |
41 | 43 | ||
42 | - objs.map((obj) => { | 44 | + if (objs.length > 0) { |
43 | - while (!obj.end()) { | 45 | + let objIdx = 0; |
44 | - console.log(obj.getCurrentFabricObject()); | 46 | + let isAddMode = true; |
47 | + const draw = () => { | ||
48 | + const obj = objs[objIdx]; | ||
49 | + if (isAddMode) { | ||
50 | + const fabricObj = obj.getCurrentFabricObject(); | ||
45 | obj.next(); | 51 | obj.next(); |
52 | + if (obj.end()) { | ||
53 | + if (objIdx < objs.length - 1) objIdx++; | ||
54 | + else this.canvas.off("after:render", draw); | ||
55 | + } else { | ||
56 | + isAddMode = false; | ||
57 | + } | ||
58 | + this.canvas.add(fabricObj); | ||
59 | + } else { | ||
60 | + this.canvas.remove( | ||
61 | + this.canvas._objects[this.canvas._objects.length - 1] | ||
62 | + ); | ||
63 | + isAddMode = true; | ||
64 | + } | ||
65 | + }; | ||
66 | + this.canvas.on("after:render", draw); | ||
67 | + draw(); | ||
46 | } | 68 | } |
47 | - }); | ||
48 | 69 | ||
49 | console.log(objs); | 70 | console.log(objs); |
50 | } | 71 | } | ... | ... |
-
Please register or login to post a comment