@@ -887,6 +887,29 @@ async function renderSidebarHTML(pageNum = 1) {
887887}
888888
889889
890+ // load more repos if scrolled to bottom of sidebar
891+ sidebar . addEventListener ( 'scroll' , ( ) => {
892+
893+ const moreButton = fileWrapper . querySelector ( '.item.more' ) ;
894+
895+ // if 'more' button exists
896+ if ( moreButton ) {
897+
898+ const maxScroll = sidebar . scrollHeight - sidebar . clientHeight ;
899+
900+ // if scrolled to bottom of sidebar
901+ if ( sidebar . scrollTop => maxScroll ) {
902+
903+ // load more repos
904+ clickedOnMoreButtonHTML ( moreButton ) ;
905+
906+ }
907+
908+ }
909+
910+ } ) ;
911+
912+
890913// adds item event listeners
891914function addHTMLItemListeners ( ) {
892915
@@ -984,14 +1007,8 @@ function addHTMLItemListeners() {
9841007 } else if ( item . classList . contains ( 'more' ) ) {
9851008
9861009 // if item is a 'more' button,
987- // show more
988-
989- const nextPage = Number ( getAttr ( item , 'nextPage' ) ) ;
990-
991- renderSidebarHTML ( nextPage ) ;
992-
993- // disable button
994- item . classList . add ( 'disabled' ) ;
1010+ // load more items
1011+ clickedOnMoreButtonHTML ( item ) ;
9951012
9961013 }
9971014
@@ -1006,6 +1023,20 @@ function addHTMLItemListeners() {
10061023}
10071024
10081025
1026+ // when clicked on more button in HTML,
1027+ // load more items
1028+ function clickedOnMoreButtonHTML ( buttonEl ) {
1029+
1030+ const nextPage = Number ( getAttr ( buttonEl , 'nextPage' ) ) ;
1031+
1032+ renderSidebarHTML ( nextPage ) ;
1033+
1034+ // disable button
1035+ buttonEl . classList . add ( 'disabled' ) ;
1036+
1037+ }
1038+
1039+
10091040// when clicked on file in HTML
10101041async function clickedOnFileHTML ( fileEl , event ) {
10111042
0 commit comments