|
@@ -51,7 +51,10 @@ import { useViewStack } from "@/hook";
|
|
|
import { ams, AnimationModel, autoSaveAnimationModel } from "@/store/animation";
|
|
|
import { computed, nextTick, onUnmounted, reactive, ref, watch, watchEffect } from "vue";
|
|
|
import { Active } from "./type";
|
|
|
-import { getAddTLItemAttr } from "@/components/drawing-time-line/check";
|
|
|
+import {
|
|
|
+ getAddTLItemAttr,
|
|
|
+ getAddTLItemTimeByTime,
|
|
|
+} from "@/components/drawing-time-line/check";
|
|
|
import { Message } from "bill/expose-common";
|
|
|
import { mergeFuns, uuid } from "@/components/drawing/hook";
|
|
|
import { title } from "./type";
|
|
@@ -69,6 +72,7 @@ import {
|
|
|
} from "@/env";
|
|
|
import { clickListener } from "@/utils/event";
|
|
|
import { useRMenus } from "@/components/right-menu";
|
|
|
+import { asyncTimeout } from "@/utils";
|
|
|
|
|
|
enterEdit(() => router.back());
|
|
|
useViewStack(autoSaveAnimationModel);
|
|
@@ -199,39 +203,42 @@ watch(
|
|
|
{ immediate: true }
|
|
|
);
|
|
|
|
|
|
-watch(activeAttrib, (_a, _b, onCleanup) => {
|
|
|
- if (!activeAttrib.value) return;
|
|
|
- const cur = focusAM.value![activeAttrib.value.key][activeAttrib.value.ndx];
|
|
|
- const updateFocus = () => {
|
|
|
- const rang = [cur.time, cur.time + (cur.duration || 0)];
|
|
|
-
|
|
|
- if (currentTime.value < rang[0] || currentTime.value > rang[1]) {
|
|
|
- activeAttrib.value = undefined;
|
|
|
- }
|
|
|
- };
|
|
|
+watch(
|
|
|
+ activeAttrib,
|
|
|
+ async (_a, _b, onCleanup) => {
|
|
|
+ console.error("activeAttrib", activeAttrib.value);
|
|
|
+ if (!activeAttrib.value) return;
|
|
|
+ const cur = focusAM.value![activeAttrib.value.key][activeAttrib.value.ndx];
|
|
|
+ const updateFocus = () => {
|
|
|
+ const rang = [cur.time, cur.time + (cur.duration || 0)];
|
|
|
|
|
|
- follow.value = true;
|
|
|
- currentTime.value = cur.time!;
|
|
|
- nextTick(() => (follow.value = false));
|
|
|
+ if (currentTime.value < rang[0] || currentTime.value > rang[1]) {
|
|
|
+ activeAttrib.value = undefined;
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- onCleanup(
|
|
|
- watch(
|
|
|
- () => [currentTime.value, cur.time, cur.time + (cur.duration || 0)],
|
|
|
- updateFocus,
|
|
|
- { flush: "sync" }
|
|
|
- )
|
|
|
- );
|
|
|
-});
|
|
|
+ follow.value = true;
|
|
|
+ currentTime.value = cur.time!;
|
|
|
+ nextTick(() => (follow.value = false));
|
|
|
+ onCleanup(
|
|
|
+ watch(
|
|
|
+ () => [currentTime.value, cur.time, cur.time + (cur.duration || 0)],
|
|
|
+ updateFocus,
|
|
|
+ { flush: "sync" }
|
|
|
+ )
|
|
|
+ );
|
|
|
+ },
|
|
|
+ { flush: "sync" }
|
|
|
+);
|
|
|
|
|
|
const add = <T extends Active["key"]>(
|
|
|
key: T,
|
|
|
preset: Partial<AnimationModel[T][0]> = {}
|
|
|
) => {
|
|
|
- const attr = getAddTLItemAttr(
|
|
|
+ const attr = getAddTLItemTimeByTime(
|
|
|
focusAM.value![key],
|
|
|
currentTime.value,
|
|
|
- preset.duration || 10,
|
|
|
- 1
|
|
|
+ preset.duration || 10
|
|
|
);
|
|
|
if (!attr) {
|
|
|
Message.error("同一时间内请勿重复添加");
|
|
@@ -239,8 +246,8 @@ const add = <T extends Active["key"]>(
|
|
|
const item = reactive({
|
|
|
id: uuid(),
|
|
|
name: title[key],
|
|
|
- ...attr,
|
|
|
...preset,
|
|
|
+ ...attr,
|
|
|
} as any);
|
|
|
if (key === "frames") {
|
|
|
asyncOper(
|
|
@@ -249,6 +256,7 @@ const add = <T extends Active["key"]>(
|
|
|
);
|
|
|
}
|
|
|
focusAM.value![key].push(item);
|
|
|
+ // currentTime.value = item.time;
|
|
|
activeAttrib.value = {
|
|
|
ndx: focusAM.value![key].length - 1,
|
|
|
key,
|