Skip to content

Commit aab07f0

Browse files
author
Hardy--Lee
committed
fix: enter exit duration could be zero
1 parent bb6a6cc commit aab07f0

4 files changed

Lines changed: 19 additions & 11 deletions

File tree

packages/webgal/src/Core/Modules/animationFunctions.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import { baseTransform } from '@/store/stageInterface';
77
import { generateTimelineObj } from '@/Core/controller/stage/pixi/animations/timeline';
88
import { WebGAL } from '@/Core/WebGAL';
99
import PixiStage, { IAnimationObject } from '@/Core/controller/stage/pixi/PixiController';
10-
import { DEFAULT_FIG_IN_DURATION, DEFAULT_FIG_OUT_DURATION } from '../constants';
10+
import {
11+
DEFAULT_BG_IN_DURATION,
12+
DEFAULT_BG_OUT_DURATION,
13+
DEFAULT_FIG_IN_DURATION,
14+
DEFAULT_FIG_OUT_DURATION,
15+
} from '../constants';
1116

1217
// eslint-disable-next-line max-params
1318
export function getAnimationObject(animationName: string, target: string, duration: number, writeDefault: boolean) {
@@ -59,7 +64,7 @@ export function getEnterExitAnimation(
5964
if (type === 'enter') {
6065
let duration = DEFAULT_FIG_IN_DURATION;
6166
if (isBg) {
62-
duration = 1500;
67+
duration = DEFAULT_BG_IN_DURATION;
6368
}
6469
duration =
6570
webgalStore.getState().stage.animationSettings.find((setting) => setting.target === target)?.enterDuration ??
@@ -83,7 +88,7 @@ export function getEnterExitAnimation(
8388
// exit
8489
let duration = DEFAULT_FIG_OUT_DURATION;
8590
if (isBg) {
86-
duration = 1500;
91+
duration = DEFAULT_BG_OUT_DURATION;
8792
}
8893
duration =
8994
webgalStore.getState().stage.animationSettings.find((setting) => setting.target + '-off' === target)

packages/webgal/src/Core/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ export const STAGE_KEYS = {
99
export const WEBGAL_NONE = 'none';
1010
export const DEFAULT_FIG_IN_DURATION = 300;
1111
export const DEFAULT_FIG_OUT_DURATION = 450;
12+
export const DEFAULT_BG_IN_DURATION = 1000;
13+
export const DEFAULT_BG_OUT_DURATION = 1500;

packages/webgal/src/Core/gameScripts/changeBg/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { AnimationFrame, IUserAnimation } from '@/Core/Modules/animations';
1313
import cloneDeep from 'lodash/cloneDeep';
1414
import { getAnimateDuration } from '@/Core/Modules/animationFunctions';
1515
import { WebGAL } from '@/Core/WebGAL';
16+
import { DEFAULT_BG_OUT_DURATION } from '@/Core/constants';
1617

1718
/**
1819
* 进行背景图片的切换
@@ -24,10 +25,10 @@ export const changeBg = (sentence: ISentence): IPerform => {
2425
const unlockName = getStringArgByKey(sentence, 'unlockname') ?? '';
2526
const series = getStringArgByKey(sentence, 'series') ?? 'default';
2627
const transformString = getStringArgByKey(sentence, 'transform');
27-
let duration = getNumberArgByKey(sentence, 'duration') ?? 1000;
28+
let duration = getNumberArgByKey(sentence, 'duration') ?? DEFAULT_BG_OUT_DURATION;
2829
const enterDuration = getNumberArgByKey(sentence, 'enterDuration') ?? duration;
2930
duration = enterDuration;
30-
const exitDuration = getNumberArgByKey(sentence, 'exitDurationOfPrev');
31+
const exitDuration = getNumberArgByKey(sentence, 'exitDurationOfPrev') ?? DEFAULT_BG_OUT_DURATION;
3132
const ease = getStringArgByKey(sentence, 'ease') ?? '';
3233

3334
const dispatch = webgalStore.dispatch;
@@ -101,12 +102,12 @@ export const changeBg = (sentence: ISentence): IPerform => {
101102
);
102103
duration = getAnimateDuration(exitAnimation);
103104
}
104-
if (enterDuration) {
105+
if (enterDuration >= 0) {
105106
webgalStore.dispatch(
106107
stageActions.updateAnimationSettings({ target: 'bg-main', key: 'enterDuration', value: enterDuration }),
107108
);
108109
}
109-
if (exitDuration) {
110+
if (exitDuration >= 0) {
110111
webgalStore.dispatch(
111112
stageActions.updateAnimationSettings({ target: 'bg-main', key: 'exitDuration', value: exitDuration }),
112113
);

packages/webgal/src/Core/gameScripts/changeFigure.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { logger } from '@/Core/util/logger';
1212
import { getAnimateDuration } from '@/Core/Modules/animationFunctions';
1313
import { WebGAL } from '@/Core/WebGAL';
1414
import { baseBlinkParam, baseFocusParam, BlinkParam, FocusParam } from '@/Core/live2DCore';
15-
import { DEFAULT_FIG_IN_DURATION, WEBGAL_NONE } from '../constants';
15+
import { DEFAULT_FIG_IN_DURATION, DEFAULT_FIG_OUT_DURATION, WEBGAL_NONE } from '../constants';
1616
/**
1717
* 更改立绘
1818
* @param sentence 语句
@@ -93,7 +93,7 @@ export function changeFigure(sentence: ISentence): IPerform {
9393
let zIndex = getNumberArgByKey(sentence, 'zIndex') ?? -1;
9494
const enterDuration = getNumberArgByKey(sentence, 'enterDuration') ?? duration;
9595
duration = enterDuration;
96-
const exitDuration = getNumberArgByKey(sentence, 'exitDurationOfPrev');
96+
const exitDuration = getNumberArgByKey(sentence, 'exitDurationOfPrev') ?? DEFAULT_FIG_OUT_DURATION;
9797

9898
const dispatch = webgalStore.dispatch;
9999

@@ -206,12 +206,12 @@ export function changeFigure(sentence: ISentence): IPerform {
206206
);
207207
duration = getAnimateDuration(exitAnimation);
208208
}
209-
if (enterDuration) {
209+
if (enterDuration >= 0) {
210210
webgalStore.dispatch(
211211
stageActions.updateAnimationSettings({ target: key, key: 'enterDuration', value: enterDuration }),
212212
);
213213
}
214-
if (exitDuration) {
214+
if (exitDuration >= 0) {
215215
webgalStore.dispatch(
216216
stageActions.updateAnimationSettings({ target: key, key: 'exitDuration', value: exitDuration }),
217217
);

0 commit comments

Comments
 (0)