feat: rotate card in portrait mode
This commit is contained in:
@@ -93,9 +93,13 @@ window.addEventListener('hashchange', onLoad, true);
|
|||||||
|
|
||||||
function onResize() {
|
function onResize() {
|
||||||
const card = document.getElementById('card');
|
const card = document.getElementById('card');
|
||||||
const sw = window.innerWidth / card.offsetWidth;
|
const [cW, cH] = [card.offsetWidth, card.offsetHeight];
|
||||||
const sh = window.innerHeight / card.offsetHeight;
|
const [wW, wH] = [window.innerWidth, window.innerHeight];
|
||||||
card.style.scale = Math.min(Math.min(sw, sh) * 0.97, 2);
|
const sL = Math.min(2, Math.min(wW / cW, wH / cH) * 0.97);
|
||||||
|
const sP = Math.min(2, Math.min(wW / cH, wH / cW) * 0.97);
|
||||||
|
const portrait = sP > sL && sL < 1.8;
|
||||||
|
card.style.scale = portrait ? sP : sL;
|
||||||
|
card.style.transform = portrait ? 'rotate(90deg)' : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('resize', onResize, true);
|
window.addEventListener('resize', onResize, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user