Skip to content

Commit eae605a

Browse files
fix(statevis): fix resize event handling
1 parent 0d97161 commit eae605a

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/statevis/StateVisWindow.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@ import { Renderer } from "./interface";
1010

1111
export interface IProps {
1212
minimized?: boolean; // ms
13-
width?: number; // px
14-
height?: number; // px
13+
onResize?: (dimensions: { width: number, height: number }) => void;
1514
}
1615

1716
export interface IState {
18-
height?: number;
19-
width?: number;
2017
unminimize: Function;
2118
}
2219

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

3633
this.state = {
37-
height: this.props.height,
38-
width: this.props.width,
3934
unminimize: null,
4035
}
4136
}
@@ -121,7 +116,7 @@ export class StateVisWindow extends Component<IProps, IState> {
121116
_height = newheight;
122117
let width = parseInt(newwidth.replace(/px$/, ""));
123118
let height = parseInt(newheight.replace(/px$/, ""));
124-
this.setState({ width, height })
119+
this.props.onResize({ width, height })
125120
}
126121
}
127122
});

src/statevis/StateVisualizer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ export class StateVisualizer extends Component<IProps, IState> {
150150
render() {
151151
const { minimized } = this.state;
152152
return (
153-
<StateVisWindow minimized={this.state.minimized} ref={(window) => this.window = window}>
153+
<StateVisWindow minimized={this.state.minimized}
154+
ref={(window) => this.window = window}
155+
onResize={({ width, height }) => this.setState({ width, height })}>
156+
154157
<div onClick={() => this.setState({ minimized: false })}
155158
className={ `uirStateVisWindowOverlay ${minimized ? "minimized" : "" }`}
156159
></div>

0 commit comments

Comments
 (0)