diff options
| author | Eltrac <hi@guhub.cn> | 2025-09-17 21:08:09 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-09-17 21:08:09 +0800 |
| commit | 58ef00994cb1924cc4e89f11821fdba5a25e3c4c (patch) | |
| tree | be2e67bc2c459604f357ee5d404d5e7a704d2de3 /src | |
| parent | 97c30098027fa8e9089807d65bbe1c40da7ffe07 (diff) | |
fix: images cannot scale properly if it's smaller than window
Diffstat (limited to 'src')
| -rw-r--r-- | src/animation.js | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/animation.js b/src/animation.js index b62fc21..6952a72 100644 --- a/src/animation.js +++ b/src/animation.js @@ -10,13 +10,14 @@ export default class Animation { if (element.naturalWidth > ww) { finals.width = ww; finals.height = ww / ratio; - if (finals.height > wh) { - finals.height = wh; - finals.width = wh * ratio; - } } else { - finals.width = element.offsetWidth; - finals.height = element.offsetHeight; + finals.width = element.naturalWidth; + finals.height = element.naturalHeight; + } + + if (finals.height > wh) { + finals.height = wh; + finals.width = wh * ratio; } finals.top = (wh - finals.height) / 2 + window.scrollY + margin; |
