X-Git-Url: https://git.auder.net/?p=xogo.git;a=blobdiff_plain;f=base_rules.js;h=311750689fdb7b797a1689e897db05b6af245c0e;hp=33411f0ef502638bd526bddf16ae669392844885;hb=a1b45f4c9f254fad73af06b4123b7208247bbba4;hpb=535c464b0543306a0ea36c66f07dcfad7a951efc diff --git a/base_rules.js b/base_rules.js index 33411f0..3117506 100644 --- a/base_rules.js +++ b/base_rules.js @@ -787,9 +787,10 @@ export default class ChessRules { if (newHeight > window.innerHeight) newHeight = window.innerHeight; const newRatio = newWidth / newHeight; - if (newRatio > self.size.ratio) + const epsilon = 1e-4; //arbitrary small value to avoid instabilities + if (newRatio - self.size.ratio > epsilon) newWidth = newHeight * self.size.ratio; - else if (newRatio < self.size.ratio) + else if (newRatio - self.size.ratio < -epsilon) newHeight = newWidth / self.size.ratio; chessboard.style.width = newWidth + "px"; chessboard.style.height = newHeight + "px";