Skip to content

Commit 8e4b7cd

Browse files
committed
scrollbar: update in next frame
the high timeout caused glitches so we assume the width has been settled in the next animation frame + plus some surplus matcornic#470
1 parent 11e7df3 commit 8e4b7cd

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

static/js/theme.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -545,22 +545,22 @@ function initMenuScrollbar(){
545545
// affect their size
546546
window.addEventListener('resize', function(){
547547
console.log("resize")
548-
pst && setTimeout( function(){ pst.update(); }, 400 );
549-
psm && setTimeout( function(){ psm.update(); }, 400 );
550-
psc && setTimeout( function(){ psc.update(); }, 400 );
548+
pst && setTimeout( function(){ pst.update(); }, 10 );
549+
psm && setTimeout( function(){ psm.update(); }, 10 );
550+
psc && setTimeout( function(){ psc.update(); }, 10 );
551551
});
552552
// now that we may have collapsible menus, we need to call a resize
553553
// for the menu scrollbar if sections are expanded/collapsed
554554
document.querySelectorAll('#sidebar .collapsible-menu input.toggle').forEach( function(e){
555555
e.addEventListener('change', function(){
556-
psm && setTimeout( function(){ psm.update(); }, 400 );
556+
psm && setTimeout( function(){ psm.update(); }, 10 );
557557
});
558558
});
559559
// bugfix for PS in RTL mode: the initial scrollbar position is off;
560560
// calling update() once, fixes this
561-
pst && setTimeout( function(){ pst.update(); }, 400 );
562-
psm && setTimeout( function(){ psm.update(); }, 400 );
563-
psc && setTimeout( function(){ psc.update(); }, 400 );
561+
pst && setTimeout( function(){ pst.update(); }, 10 );
562+
psm && setTimeout( function(){ psm.update(); }, 10 );
563+
psc && setTimeout( function(){ psc.update(); }, 10 );
564564

565565
// finally, we want to adjust the contents end padding if there is a scrollbar visible
566566
window.addEventListener('resize', adjustContentWidth );
@@ -668,7 +668,7 @@ function showToc(){
668668
var b = document.querySelector( 'body' );
669669
b.classList.toggle( 'toc-flyout' );
670670
if( b.classList.contains( 'toc-flyout' ) ){
671-
pst && setTimeout( function(){ pst.update(); }, 400 );
671+
pst && setTimeout( function(){ pst.update(); }, 10 );
672672
pst && pst.scrollbarY.focus();
673673
document.querySelector( '.toc-wrapper ul a' ).focus();
674674
document.addEventListener( 'keydown', tocEscapeHandler );
@@ -882,7 +882,7 @@ function mark() {
882882
parent = parent.parentNode;
883883
}
884884
}
885-
psm && setTimeout( function(){ psm.update(); }, 400 );
885+
psm && setTimeout( function(){ psm.update(); }, 10 );
886886
}
887887
window.relearn.markSearch = mark;
888888

@@ -970,7 +970,7 @@ function unmark() {
970970

971971
var highlighted = document.querySelectorAll( '.highlightable' );
972972
unhighlight( highlighted, { element: 'mark' } );
973-
psm && setTimeout( function(){ psm.update(); }, 400 );
973+
psm && setTimeout( function(){ psm.update(); }, 10 );
974974
}
975975

976976
function unhighlight( es, options ){

0 commit comments

Comments
 (0)