- const newRatio = r.width / r.height;
- let newWidth = r.width,
- newHeight = r.height;
- if (newRatio > this.size.ratio) {
- newWidth = r.height * this.size.ratio;
- chessboard.style.width = newWidth + "px";
- }
- else if (newRatio < this.size.ratio) {
- newHeight = r.width / this.size.ratio;
- chessboard.style.height = newHeight + "px";
- }
+ const multFact = (mode == "up" ? 1.05 : 0.95);
+ let [newWidth, newHeight] = [multFact * r.width, multFact * r.height];
+ // Stay in window:
+ const vRatio = this.size.ratio || 1;
+ if (newWidth > window.innerWidth) {
+ newWidth = window.innerWidth;
+ newHeight = newWidth / vRatio;
+ }
+ if (newHeight > window.innerHeight) {
+ newHeight = window.innerHeight;
+ newWidth = newHeight * vRatio;
+ }
+ chessboard.style.width = newWidth + "px";
+ chessboard.style.height = newHeight + "px";