diff --git a/src/Components/SVG/SVG.tsx b/src/Components/SVG/SVG.tsx index 9c81f00..d2cc1b2 100644 --- a/src/Components/SVG/SVG.tsx +++ b/src/Components/SVG/SVG.tsx @@ -11,8 +11,37 @@ interface ISVGProps { selected: ContainerModel | null } +interface ISVGState { + viewerWidth: number, + viewerHeight: number, +} + export class SVG extends React.PureComponent { public static ID = 'svg'; + public state: ISVGState; + + constructor(props: ISVGProps) { + super(props); + this.state = { + viewerWidth: window.innerWidth, + viewerHeight: window.innerHeight + }; + } + + resizeViewBox(): void { + this.setState({ + viewerWidth: window.innerWidth, + viewerHeight: window.innerHeight + }); + } + + componentDidMount(): void { + window.addEventListener('resize', this.resizeViewBox.bind(this)); + } + + componentWillUnmount(): void { + window.removeEventListener('resize', this.resizeViewBox.bind(this)); + } render(): JSX.Element { const xmlns = ''; @@ -33,8 +62,8 @@ export class SVG extends React.PureComponent { return (