From 1b6545fa653df44b019f6676faed39880999b2bf Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Mon, 21 Aug 2017 12:08:41 +0200 Subject: Add basic react-konva rendering prototype --- src/components/map/MapStage.js | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/components/map/MapStage.js (limited to 'src/components/map/MapStage.js') diff --git a/src/components/map/MapStage.js b/src/components/map/MapStage.js new file mode 100644 index 00000000..38047064 --- /dev/null +++ b/src/components/map/MapStage.js @@ -0,0 +1,55 @@ +import React from "react"; +import {Group, Layer, Stage} from "react-konva"; +import jQuery from "../../util/jquery"; +import Backdrop from "./elements/Backdrop"; +import GridGroup from "./groups/GridGroup"; +import RoomGroup from "./groups/RoomGroup"; +import {MAP_SIZE_IN_PIXELS} from "./MapConstants"; + +class MapStage extends React.Component { + state = { + width: 600, + height: 400 + }; + + componentWillMount() { + this.updateDimensions(); + } + + componentDidMount() { + window.addEventListener("resize", this.updateDimensions.bind(this)); + } + + componentWillUnmount() { + window.removeEventListener("resize", this.updateDimensions.bind(this)); + } + + updateDimensions() { + this.setState({width: jQuery(window).width(), height: jQuery(window).height()}); + } + + dragBoundHandler(pos) { + return { + x: pos.x > 0 ? 0 : + (pos.x < -MAP_SIZE_IN_PIXELS + this.state.width ? -MAP_SIZE_IN_PIXELS + this.state.width : pos.x), + y: pos.y > 0 ? 0 : + (pos.y < -MAP_SIZE_IN_PIXELS + this.state.height ? -MAP_SIZE_IN_PIXELS + this.state.height : pos.y) + } + } + + render() { + return ( + + + + + + + + + + ) + } +} + +export default MapStage; -- cgit v1.2.3