Skip to content

Commit

Permalink
fix scroll on loaded game tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
KilMer56 committed Dec 12, 2024
1 parent 02498b5 commit 0697b1d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions javascript/commons/BattleRoyale.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ liquipedia.battleRoyale = {
}
} );

Object.entries( this.battleRoyaleMap[ battleRoyaleId ].gamePanels[ matchContentId ] )
.forEach( ( [ , panel ] ) => {
this.makeSortableTableFromElement( panel );
} );

// Trigger countdown initialization since we have new dates
liquipedia.countdown.init();
} );
Expand Down Expand Up @@ -605,9 +610,15 @@ liquipedia.battleRoyale = {
}
},

makeSortableTable: function( battleRoyaleElement ) {
const sortButtons =
battleRoyaleElement.querySelectorAll( '[data-js-battle-royale="header-row"] > [data-sort-type]' );
makeSortableTable: function( battleRoyaleId ) {
this.battleRoyaleMap[ battleRoyaleId ].matchContents.forEach( ( matchContentElement ) => {
this.makeSortableTableFromElement( matchContentElement );
} );
},

makeSortableTableFromElement: function( targetElement ) {
const sortButtons = targetElement
.querySelectorAll( '[data-js-battle-royale="header-row"] > [data-sort-type]' );

sortButtons.forEach( ( button ) => {
button.addEventListener( 'click', () => {
Expand Down Expand Up @@ -690,7 +701,6 @@ liquipedia.battleRoyale = {
init: function() {
Array.from( document.querySelectorAll( '[ data-js-battle-royale-id ]' ) ).forEach( ( battleRoyaleElement ) => {
this.battleRoyaleInstances[ battleRoyaleElement.dataset.jsBattleRoyaleId ] = battleRoyaleElement;
this.makeSortableTable( battleRoyaleElement );
} );

Object.keys( this.battleRoyaleInstances ).forEach( ( battleRoyaleId ) => {
Expand All @@ -701,6 +711,8 @@ liquipedia.battleRoyale = {

this.attachHandlers( battleRoyaleId );
this.makeCollapsibles( battleRoyaleId );
this.makeSortableTable( battleRoyaleId );

if ( !this.isMobile() ) {
this.makeSideScrollElements( battleRoyaleId );
this.makeTableScrollHint( battleRoyaleId );
Expand Down

0 comments on commit 0697b1d

Please sign in to comment.