diff --git a/packages/react-scenejs-timeline/src/react-scenejs-timeline/Timeline.tsx b/packages/react-scenejs-timeline/src/react-scenejs-timeline/Timeline.tsx index 8eeb825..eac2e48 100644 --- a/packages/react-scenejs-timeline/src/react-scenejs-timeline/Timeline.tsx +++ b/packages/react-scenejs-timeline/src/react-scenejs-timeline/Timeline.tsx @@ -39,6 +39,7 @@ export default class Timeline extends PureProps { selectedProperty: "", selectedTime: -1, init: false, + updateTime: false, }; private isExportCSS = false; private axes!: Axes; @@ -137,15 +138,19 @@ export default class Timeline extends PureProps { this.initKeyController(); } public componentDidUpdate(prevProps: TimelineProps, prevState: TimelineState) { - if (this.state.init) { - this.state.init = false; + const state = this.state; + + if (state.init) { + state.init = false; this.scrollArea.foldAll(); } if (prevProps.scene !== this.props.scene) { this.releaseScene(prevProps.scene); this.setState(this.initScene(this.props.scene, true)); - } else { + } + if (state.updateTime) { + state.updateTime = false; this.setTime(); } } @@ -171,6 +176,7 @@ export default class Timeline extends PureProps { timelineInfo: getTimelineInfo(scene), maxTime, maxDuration, + updateTime: true, init: isInit, }); @@ -536,10 +542,11 @@ export default class Timeline extends PureProps { } private initKeyController() { window.addEventListener("blur", () => { - this.setState({ alt: false }); + if (this.state.alt === true) { + this.setState({ alt: false }); + } }); - // if (props.keyboard) { if (this.props.keyboard) { this.keycon!.keydown("space", ({ inputEvent }) => { inputEvent.preventDefault(); diff --git a/packages/react-scenejs-timeline/src/react-scenejs-timeline/types.ts b/packages/react-scenejs-timeline/src/react-scenejs-timeline/types.ts index ec738a3..23785ef 100644 --- a/packages/react-scenejs-timeline/src/react-scenejs-timeline/types.ts +++ b/packages/react-scenejs-timeline/src/react-scenejs-timeline/types.ts @@ -25,6 +25,7 @@ export interface TimelineState { timelineInfo: TimelineInfo; selectedProperty: string; selectedTime: number; + updateTime: boolean; init: boolean; } export interface PropertiesInfo {