| | |
| | | import './index.css' |
| | | import { createStyles } from 'antd-style'; |
| | | import Edit from './components/edit' |
| | | import * as Utils from './utils' |
| | | |
| | | const useStyles = createStyles(({ token }) => { |
| | | let dark = token.colorBgBase === '#000'; |
| | |
| | | }); |
| | | |
| | | React.useEffect(() => { |
| | | |
| | | Utils.syncApp(app); |
| | | Utils.syncMapContainer(mapContainer); |
| | | |
| | | const handleResize = () => { |
| | | setWindowSize({ |
| | | width: window.innerWidth, |
| | |
| | | } |
| | | |
| | | const onDrop = (sprite, x, y) => { |
| | | const rect = app.view.getBoundingClientRect(); |
| | | sprite.anchor.set(0.5); |
| | | sprite.x = x - rect.left; |
| | | sprite.y = y - rect.top; |
| | | const { mapX, mapY } = Utils.getRealPosition(x, y); |
| | | sprite.x = mapX; |
| | | sprite.y = mapY; |
| | | mapContainer.addChild(sprite); |
| | | } |
| | | |
| | |
| | | |
| | | <Edit |
| | | open={editModalVisible} |
| | | onCancel={ |
| | | () => { |
| | | setEditModalVisible(false); |
| | | } |
| | | } |
| | | onCancel={() => { |
| | | setEditModalVisible(false); |
| | | }} |
| | | refCurr={mapRef.current} |
| | | onDrop={onDrop} |
| | | mapContainer={mapContainer} |