mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-15 02:24:04 +00:00
fix(core): 🐛 incorrect sticky header class assignment
This commit is contained in:
parent
27bca0fc66
commit
af3d72ad75
|
@ -34,8 +34,8 @@ function initStickyHeader( document ) {
|
||||||
const addScrollDownClass = toggleScrollClass( SCROLL_UP_CLASS, SCROLL_DOWN_CLASS );
|
const addScrollDownClass = toggleScrollClass( SCROLL_UP_CLASS, SCROLL_DOWN_CLASS );
|
||||||
const addScrollUpClass = toggleScrollClass( SCROLL_DOWN_CLASS, SCROLL_UP_CLASS );
|
const addScrollUpClass = toggleScrollClass( SCROLL_DOWN_CLASS, SCROLL_UP_CLASS );
|
||||||
|
|
||||||
const toggleStickyClass = () => {
|
const toggleStickyClass = ( state ) => {
|
||||||
return ( state ) => {
|
return () => {
|
||||||
window.requestAnimationFrame( () => {
|
window.requestAnimationFrame( () => {
|
||||||
document.body.classList.toggle( STICKY_CLASS, state );
|
document.body.classList.toggle( STICKY_CLASS, state );
|
||||||
} );
|
} );
|
||||||
|
@ -45,8 +45,9 @@ function initStickyHeader( document ) {
|
||||||
initDirectionObserver( addScrollDownClass, addScrollUpClass, 10 );
|
initDirectionObserver( addScrollDownClass, addScrollUpClass, 10 );
|
||||||
|
|
||||||
const sentinel = document.getElementById( STICKY_SENTINEL_ID );
|
const sentinel = document.getElementById( STICKY_SENTINEL_ID );
|
||||||
|
const shouldStickyHeader = sentinel && getComputedStyle( sentinel ).getPropertyValue( 'display' ) !== 'none';
|
||||||
|
|
||||||
if ( sentinel && getComputedStyle( sentinel ).getPropertyValue( 'display' ) !== 'none' ) {
|
if ( shouldStickyHeader ) {
|
||||||
const observer = initIntersectionObserver( toggleStickyClass( true ), toggleStickyClass( false ) );
|
const observer = initIntersectionObserver( toggleStickyClass( true ), toggleStickyClass( false ) );
|
||||||
observer.observe( sentinel );
|
observer.observe( sentinel );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue