Skip to content

Commit

Permalink
fix: fix setTime timing
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Jun 9, 2019
1 parent 172714c commit db9fa60
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class Timeline extends PureProps<TimelineProps, TimelineState> {
selectedProperty: "",
selectedTime: -1,
init: false,
updateTime: false,
};
private isExportCSS = false;
private axes!: Axes;
Expand Down Expand Up @@ -137,15 +138,19 @@ export default class Timeline extends PureProps<TimelineProps, TimelineState> {
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();
}
}
Expand All @@ -171,6 +176,7 @@ export default class Timeline extends PureProps<TimelineProps, TimelineState> {
timelineInfo: getTimelineInfo(scene),
maxTime,
maxDuration,
updateTime: true,
init: isInit,
});

Expand Down Expand Up @@ -536,10 +542,11 @@ export default class Timeline extends PureProps<TimelineProps, TimelineState> {
}
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface TimelineState {
timelineInfo: TimelineInfo;
selectedProperty: string;
selectedTime: number;
updateTime: boolean;
init: boolean;
}
export interface PropertiesInfo {
Expand Down

0 comments on commit db9fa60

Please sign in to comment.