Fix resize
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
7270d29a81
commit
94eb98ee37
@ -25,6 +25,7 @@ const
|
||||
const Board = () => {
|
||||
const { ws } = useContext(GlobalContext);
|
||||
const board = useRef();
|
||||
const [transform, setTransform] = useState(1.);
|
||||
const [pipElements, setPipElements] = useState(<></>);
|
||||
const [borderElements, setBorderElements] = useState(<></>);
|
||||
const [tileElements, setTileElements] = useState(<></>);
|
||||
@ -148,12 +149,19 @@ const Board = () => {
|
||||
}));
|
||||
}, [ws, fields]);
|
||||
|
||||
useEffect(() => {
|
||||
const boardBox = board.current.querySelector('.BoardBox');
|
||||
if (boardBox) {
|
||||
console.log(`board - setting transform scale to ${transform}`);
|
||||
boardBox.style.transform = `scale(${transform})`;
|
||||
}
|
||||
}, [transform]);
|
||||
|
||||
const onResize = debounce(() => {
|
||||
if (!board.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`board - resize`);
|
||||
/* Adjust the 'transform: scale' for the BoardBox
|
||||
* so the board fills the Board
|
||||
*
|
||||
@ -167,12 +175,8 @@ const Board = () => {
|
||||
_transform = height / (450.);
|
||||
}
|
||||
|
||||
const boardBox = board.current.querySelector('.BoardBox');
|
||||
if (boardBox) {
|
||||
console.log(`board - setting transform scale to ${_transform}`);
|
||||
if (boardBox.style.transform !== `scale(${_transform})`) {
|
||||
boardBox.style.transform = `scale(${_transform})`;
|
||||
}
|
||||
if (transform !== transform) {
|
||||
setTransform(_transform);
|
||||
}
|
||||
}, 250);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user