forked from rlottie/rlottie.github.io
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paththumbnail-handler.js
More file actions
44 lines (40 loc) · 1.2 KB
/
thumbnail-handler.js
File metadata and controls
44 lines (40 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class ThumbnailHandler {
constructor(layers) {
this.rlotties = [];
layers.forEach(l => {
var rm = new RLottieModule(l.id, true);
this.makeThumbnail(rm, l.keypath, l.type);
this.rlotties.push(rm);
});
}
render() {
this.rlotties.forEach(rm => {
rm.render(1);
if (rm.curFrame >= rm.frameCount) rm.curFrame = 0;
})
}
reload(layers, jsString) {
setTimeout(() => {
this.rlotties = [];
layers.forEach(l => {
var rm = new RLottieModule(l.id, true);
rm.lottieHandle.load(jsString);
this.makeThumbnail(rm, l.keypath, l.type);
this.rlotties.push(rm);
});
}, 500)
}
setModuleCanvas(layers) {
for (let i = 0; i < layers.length; i++) {
this.rlotties[i].canvasId = layers[i].id;
this.rlotties[i].canvas = document.getElementById(layers[i].id);
this.rlotties[i].context = this.rlotties[i].canvas.getContext("2d");
}
}
makeThumbnail(module, keypath, type) {
module.lottieHandle.setFillOpacity("**", 0);
module.lottieHandle.setStrokeOpacity("**", 0);
module.lottieHandle.setFillOpacity(keypath + ".**", 100);
module.lottieHandle.setStrokeOpacity(keypath + ".**", 100);
}
}