미디어위키:Gadget-Vector.js: 두 판 사이의 차이
식물 vs 좀비 위키
편집 요약 없음 |
편집 요약 없음 |
||
| 429번째 줄: | 429번째 줄: | ||
} else { | } else { | ||
initRightNavigationAlignment(); | initRightNavigationAlignment(); | ||
} | |||
}()); | |||
(function () { | |||
'use strict'; | |||
function syncV32Navigation() { | |||
var content = document.querySelector('#content'); | |||
var leftNavigation = document.getElementById('left-navigation'); | |||
var rightNavigation = document.getElementById('right-navigation'); | |||
var rightGap; | |||
var navigationTop; | |||
if (!content || !leftNavigation || !rightNavigation) { | |||
return; | |||
} | |||
rightGap = Math.max( | |||
0, | |||
window.innerWidth - content.getBoundingClientRect().right | |||
); | |||
navigationTop = | |||
leftNavigation.getBoundingClientRect().top + | |||
window.scrollY; | |||
document.documentElement.style.setProperty( | |||
'--pvz-content-right-gap', | |||
rightGap + 'px' | |||
); | |||
document.documentElement.style.setProperty( | |||
'--pvz-navigation-top', | |||
navigationTop + 'px' | |||
); | |||
rightNavigation.style.setProperty( | |||
'top', | |||
navigationTop + 'px', | |||
'important' | |||
); | |||
rightNavigation.style.setProperty( | |||
'right', | |||
(rightGap + 15) + 'px', | |||
'important' | |||
); | |||
rightNavigation.style.setProperty( | |||
'left', | |||
'auto', | |||
'important' | |||
); | |||
} | |||
function initV32Navigation() { | |||
var observer; | |||
syncV32Navigation(); | |||
window.addEventListener( | |||
'resize', | |||
syncV32Navigation, | |||
{ passive: true } | |||
); | |||
window.addEventListener( | |||
'orientationchange', | |||
syncV32Navigation, | |||
{ passive: true } | |||
); | |||
observer = new MutationObserver(function () { | |||
window.requestAnimationFrame(syncV32Navigation); | |||
}); | |||
observer.observe(document.body, { | |||
childList: true, | |||
subtree: true | |||
}); | |||
} | |||
if (document.readyState === 'loading') { | |||
document.addEventListener( | |||
'DOMContentLoaded', | |||
initV32Navigation, | |||
{ once: true } | |||
); | |||
} else { | |||
initV32Navigation(); | |||
} | } | ||
}()); | }()); | ||
