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 Board = () => {
|
||||||
const { ws } = useContext(GlobalContext);
|
const { ws } = useContext(GlobalContext);
|
||||||
const board = useRef();
|
const board = useRef();
|
||||||
|
const [transform, setTransform] = useState(1.);
|
||||||
const [pipElements, setPipElements] = useState(<></>);
|
const [pipElements, setPipElements] = useState(<></>);
|
||||||
const [borderElements, setBorderElements] = useState(<></>);
|
const [borderElements, setBorderElements] = useState(<></>);
|
||||||
const [tileElements, setTileElements] = useState(<></>);
|
const [tileElements, setTileElements] = useState(<></>);
|
||||||
@ -148,12 +149,19 @@ const Board = () => {
|
|||||||
}));
|
}));
|
||||||
}, [ws, fields]);
|
}, [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(() => {
|
const onResize = debounce(() => {
|
||||||
if (!board.current) {
|
if (!board.current) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`board - resize`);
|
|
||||||
/* Adjust the 'transform: scale' for the BoardBox
|
/* Adjust the 'transform: scale' for the BoardBox
|
||||||
* so the board fills the Board
|
* so the board fills the Board
|
||||||
*
|
*
|
||||||
@ -167,12 +175,8 @@ const Board = () => {
|
|||||||
_transform = height / (450.);
|
_transform = height / (450.);
|
||||||
}
|
}
|
||||||
|
|
||||||
const boardBox = board.current.querySelector('.BoardBox');
|
if (transform !== transform) {
|
||||||
if (boardBox) {
|
setTransform(_transform);
|
||||||
console.log(`board - setting transform scale to ${_transform}`);
|
|
||||||
if (boardBox.style.transform !== `scale(${_transform})`) {
|
|
||||||
boardBox.style.transform = `scale(${_transform})`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, 250);
|
}, 250);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user