diff options
Diffstat (limited to 'app/assets/javascripts/logo.js')
-rw-r--r-- | app/assets/javascripts/logo.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/assets/javascripts/logo.js b/app/assets/javascripts/logo.js index ca3f1caec67..c76e44a196d 100644 --- a/app/assets/javascripts/logo.js +++ b/app/assets/javascripts/logo.js @@ -3,3 +3,20 @@ export default function initLogoAnimation() { document.querySelector('.tanuki-logo')?.classList.add('animate'); }); } + +export function initPortraitLogoDetection() { + const image = document.querySelector('.js-portrait-logo-detection'); + + image?.addEventListener( + 'load', + ({ currentTarget: img }) => { + const isPortrait = img.height > img.width; + if (isPortrait) { + // Limit the width when the logo has portrait format + img.classList.replace('gl-h-9', 'gl-w-10'); + } + img.classList.remove('gl-visibility-hidden'); + }, + { once: true }, + ); +} |