From 536562c061fef1e6ddb524f8bf3fec4d6f1813b5 Mon Sep 17 00:00:00 2001 From: cha0s Date: Thu, 24 Mar 2022 07:34:40 -0500 Subject: [PATCH] refactor: vector --- packages/topdown/src/components/room.jsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/topdown/src/components/room.jsx b/packages/topdown/src/components/room.jsx index 5b0a696..f6bf6e7 100644 --- a/packages/topdown/src/components/room.jsx +++ b/packages/topdown/src/components/room.jsx @@ -1,3 +1,4 @@ +import {Vector} from '@avocado/math'; import { PropTypes, React, @@ -10,9 +11,8 @@ import styles from './room.module.scss'; // This is the DOM side of a rendered room. Dialog text, damage numbers, (DOM node entities)... function Room({ domScale, - left, + position, room, - top, }) { const ref = useRef(); useEffect(() => { @@ -41,8 +41,9 @@ function Room({ if (!ref.current || !room) { return; } + const translated = Vector.mul(position, domScale); ref.current - .style.transform = `translate(${left * domScale[0]}px, ${top * domScale[1]}px)`; + .style.transform = `translate(${translated[0]}px, ${translated[1]}px)`; }); return (
@@ -58,13 +59,12 @@ Room.defaultProps = { Room.propTypes = { // @todo Real prop type domScale: PropTypes.arrayOf(PropTypes.number).isRequired, - left: PropTypes.number.isRequired, + position: PropTypes.arrayOf(PropTypes.number).isRequired, room: PropTypes.shape({ entities: PropTypes.shape({}), off: PropTypes.func, on: PropTypes.func, }), - top: PropTypes.number.isRequired, }; export default Room;