|
@@ -22,6 +22,7 @@ import { diffArrayChange, mount } from "@/utils";
|
|
|
import { Pos } from "@/utils/event";
|
|
|
import Subtitle from "@/components/subtitle/index.vue";
|
|
|
import { Size } from "@/components/drawing/dec";
|
|
|
+import router, { RoutesName } from "@/router";
|
|
|
|
|
|
export let animationGroup: AnimationGroup;
|
|
|
export const getAMKey = (am: AnimationModel) => am.key || am.id;
|
|
@@ -320,8 +321,10 @@ export const addSubtitle = (data: AnimationModelSubtitle) => {
|
|
|
|
|
|
|
|
|
const stopAttrib = mergeFuns(
|
|
|
- watch([currentTime, () => amMap[am.id].am, size], (_a, _b, onCleanup) => {
|
|
|
- if (
|
|
|
+ watch([currentTime, () => amMap[am.id].am, size, play], (_a, _b, onCleanup) => {
|
|
|
+ if (!play.value && router.currentRoute.value.name !== RoutesName.animation) {
|
|
|
+ show.value = false
|
|
|
+ } else if (
|
|
|
currentTime.value >= data.time &&
|
|
|
currentTime.value <= (data.time + data.duration)
|
|
|
) {
|
|
@@ -357,7 +360,19 @@ export const endTime = computed(() => {
|
|
|
);
|
|
|
return Math.max(...endPoints);
|
|
|
})
|
|
|
- return Math.max(...amsEndTime) + animationGroup.delayEndTime()
|
|
|
+ return Math.max(...amsEndTime) + (animationGroup.delayEndTime && animationGroup.delayEndTime() || 0)
|
|
|
+})
|
|
|
+
|
|
|
+export const play = ref(false);
|
|
|
+watch(play, (_a, _b, onCleanup) => {
|
|
|
+ play.value ? animationGroup?.play() : animationGroup?.pause();
|
|
|
+ onCleanup(
|
|
|
+ watchEffect(() => {
|
|
|
+ if (currentTime.value >= endTime.value) {
|
|
|
+ play.value = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ );
|
|
|
})
|
|
|
|
|
|
export const currentTime = ref(0);
|