@lijuhong1981/jsgif 1.0.11 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +9 -16
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Check from "@lijuhong1981/jscheck";
|
|
2
|
-
import { Destroyable, destroyHTMLElement, destroyObject } from "@lijuhong1981/jsdestroy";
|
|
2
|
+
import { defineDestroyProperties, Destroyable, destroyHTMLElement, destroyObject } from "@lijuhong1981/jsdestroy";
|
|
3
|
+
import { EventRaiser } from "@lijuhong1981/events";
|
|
3
4
|
import { fetchArrayBuffer } from "@lijuhong1981/jsload";
|
|
4
5
|
|
|
5
6
|
// 转流数组
|
|
@@ -145,6 +146,7 @@ function GifPlayer(options = {}) {
|
|
|
145
146
|
let TRANSPARENCY = null;
|
|
146
147
|
let isPlaying = false;
|
|
147
148
|
let currentFrameIndex = 0;
|
|
149
|
+
const frameChanged = new EventRaiser();
|
|
148
150
|
const player = {};
|
|
149
151
|
|
|
150
152
|
function reset() {
|
|
@@ -464,9 +466,7 @@ function GifPlayer(options = {}) {
|
|
|
464
466
|
function drawCurrentFrame() {
|
|
465
467
|
const frame = FRAME_LIST[currentFrameIndex];
|
|
466
468
|
drawFrame(frame);
|
|
467
|
-
|
|
468
|
-
options.onFrameChanged(currentFrameIndex, frame);
|
|
469
|
-
}
|
|
469
|
+
frameChanged.raiseEvent(currentFrameIndex, frame);
|
|
470
470
|
return frame;
|
|
471
471
|
}
|
|
472
472
|
|
|
@@ -552,6 +552,7 @@ function GifPlayer(options = {}) {
|
|
|
552
552
|
}
|
|
553
553
|
|
|
554
554
|
function destroyGif() {
|
|
555
|
+
frameChanged.clear();
|
|
555
556
|
stopGif();
|
|
556
557
|
destroyHTMLElement(CANVAS);
|
|
557
558
|
destroyHTMLElement(TEMP_CANVAS);
|
|
@@ -634,22 +635,14 @@ function GifPlayer(options = {}) {
|
|
|
634
635
|
return options.timeScale;
|
|
635
636
|
}
|
|
636
637
|
},
|
|
637
|
-
|
|
638
|
-
set: function (value) {
|
|
639
|
-
options.onFrameChanged = value;
|
|
640
|
-
},
|
|
638
|
+
frameChanged: {
|
|
641
639
|
get: function () {
|
|
642
|
-
return
|
|
640
|
+
return frameChanged;
|
|
643
641
|
}
|
|
644
|
-
}
|
|
645
|
-
destroy: {
|
|
646
|
-
value: destroyGif,
|
|
647
|
-
},
|
|
642
|
+
}
|
|
648
643
|
});
|
|
649
644
|
|
|
650
|
-
player
|
|
651
|
-
return false;
|
|
652
|
-
};
|
|
645
|
+
defineDestroyProperties(player, destroyGif);
|
|
653
646
|
|
|
654
647
|
return player;
|
|
655
648
|
};
|