Skip to content

Commit

Permalink
fix(statevis): fix resize event handling
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Dec 1, 2017
1 parent 0d97161 commit eae605a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
9 changes: 2 additions & 7 deletions src/statevis/StateVisWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ import { Renderer } from "./interface";

export interface IProps {
minimized?: boolean; // ms
width?: number; // px
height?: number; // px
onResize?: (dimensions: { width: number, height: number }) => void;
}

export interface IState {
height?: number;
width?: number;
unminimize: Function;
}

Expand All @@ -34,8 +31,6 @@ export class StateVisWindow extends Component<IProps, IState> {
super(props);

this.state = {
height: this.props.height,
width: this.props.width,
unminimize: null,
}
}
Expand Down Expand Up @@ -121,7 +116,7 @@ export class StateVisWindow extends Component<IProps, IState> {
_height = newheight;
let width = parseInt(newwidth.replace(/px$/, ""));
let height = parseInt(newheight.replace(/px$/, ""));
this.setState({ width, height })
this.props.onResize({ width, height })
}
}
});
Expand Down
5 changes: 4 additions & 1 deletion src/statevis/StateVisualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ export class StateVisualizer extends Component<IProps, IState> {
render() {
const { minimized } = this.state;
return (
<StateVisWindow minimized={this.state.minimized} ref={(window) => this.window = window}>
<StateVisWindow minimized={this.state.minimized}
ref={(window) => this.window = window}
onResize={({ width, height }) => this.setState({ width, height })}>

<div onClick={() => this.setState({ minimized: false })}
className={ `uirStateVisWindowOverlay ${minimized ? "minimized" : "" }`}
></div>
Expand Down

0 comments on commit eae605a

Please sign in to comment.