1 | const Animation = require("../animation");
|
2 | const Led = require("./led");
|
3 | const Collection = require("../mixins/collection");
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | class Leds extends Collection {
|
15 | constructor(numsOrObjects) {
|
16 | super(numsOrObjects);
|
17 | }
|
18 | get type() {
|
19 | return Led;
|
20 | }
|
21 |
|
22 | |
23 |
|
24 |
|
25 |
|
26 |
|
27 | [Animation.normalize](keyFrameSet) {
|
28 | return keyFrameSet.map((keyFrames, index) => {
|
29 | if (keyFrames !== null) {
|
30 | return this[index][Animation.normalize](keyFrames);
|
31 | }
|
32 | return keyFrames;
|
33 | });
|
34 | }
|
35 |
|
36 | |
37 |
|
38 |
|
39 |
|
40 |
|
41 | [Animation.render](frames) {
|
42 | return this.each((led, i) => led[Animation.render]([frames[i]]));
|
43 | }
|
44 | }
|
45 |
|
46 | Collection.installMethodForwarding(
|
47 | Leds.prototype, Led.prototype,
|
48 | {
|
49 | skip: [Animation.normalize, Animation.render]
|
50 | }
|
51 | );
|
52 |
|
53 | Collection.installCallbackReconciliation(
|
54 | Leds.prototype,
|
55 | ["pulse", "fade", "fadeIn", "fadeOut", "blink"]
|
56 | );
|
57 |
|
58 |
|
59 | Led.Collection = Leds;
|
60 |
|
61 | module.exports = Leds;
|