Transform scaling is working
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
6b6f1211f1
commit
ade3bb0830
@ -10,8 +10,9 @@ const Board = ({ game }) => {
|
||||
const [pips, setPips] = useState(<></>);
|
||||
const [borders, setBorders] = useState(<></>);
|
||||
const [tiles, setTiles] = useState(<></>);
|
||||
const [scale] = useState(1);
|
||||
const [transform, setTransform] = useState(1);
|
||||
|
||||
const scale = 1;
|
||||
const
|
||||
hexRatio = 1.1547,
|
||||
tileWidth = scale * 67,
|
||||
@ -132,6 +133,26 @@ const
|
||||
}
|
||||
}
|
||||
|
||||
const board = document.querySelector('.Board');
|
||||
if (board) {
|
||||
const width = board.offsetWidth,
|
||||
height = board.offsetHeight;
|
||||
let _transform;
|
||||
if (width * hexRatio > height) {
|
||||
_transform = height / (450. * hexRatio);
|
||||
} else {
|
||||
_transform = width / (450. * hexRatio);
|
||||
}
|
||||
if (_transform != transform) {
|
||||
const boardBox = board.querySelector('.BoardBox');
|
||||
if (boardBox) {
|
||||
console.log(`Setting transofrm scale to ${_transform}`);
|
||||
boardBox.style.transform = `scale(${_transform})`;
|
||||
}
|
||||
setTransform(_transform);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="Board">
|
||||
<div className="BoardBox">
|
||||
|
Loading…
x
Reference in New Issue
Block a user