mirror of
https://github.com/StarCitizenTools/mediawiki-extensions-TabberNeue.git
synced 2024-11-24 00:13:28 +00:00
feat: change tab when URL hash matches one of the tabs
Added an event listener to watch for hash change after the page is loaded. If the hash matches a tabber tab, it will emit a tab click to switch the tab. Closes: #150
This commit is contained in:
parent
d453adde07
commit
421c42b6f0
|
@ -680,9 +680,16 @@ async function load( tabberEls ) {
|
|||
await tabberBuilder.init( urlHash );
|
||||
} ) );
|
||||
|
||||
// Delay animation execution so it doesn't not animate the tab gets into position on load
|
||||
setTimeout( () => {
|
||||
// Delay animation execution so it doesn't not animate the tab gets into position on load
|
||||
TabberAction.toggleAnimation( true );
|
||||
window.addEventListener( 'hashchange', () => {
|
||||
const newHash = window.location.hash.slice( 1 );
|
||||
const tab = document.getElementById( `tab-${ CSS.escape( newHash ) }` );
|
||||
if ( tab ) {
|
||||
tab.click();
|
||||
}
|
||||
} );
|
||||
}, 250 );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue