File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
packages/webui/src/client/lib Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -190,13 +190,19 @@ function getElementToScrollTo(
190190 return elementToScrollToOrSegmentId
191191}
192192
193+ let pendingFirstStageTimeout : NodeJS . Timeout | undefined
194+
193195async function innerScrollToSegment (
194196 elementToScrollTo : HTMLElement ,
195197 forceScroll ?: boolean ,
196198 noAnimation ?: boolean ,
197199 secondStage ?: boolean
198200) : Promise < boolean > {
199201 if ( ! secondStage ) {
202+ if ( pendingFirstStageTimeout ) {
203+ clearTimeout ( pendingFirstStageTimeout )
204+ pendingFirstStageTimeout = undefined
205+ }
200206 currentScrollingElement = elementToScrollTo
201207 } else if ( secondStage && elementToScrollTo !== currentScrollingElement ) {
202208 throw new Error ( 'Scroll overriden by another scroll' )
@@ -223,7 +229,8 @@ async function innerScrollToSegment(
223229 return new Promise < boolean > ( ( resolve , reject ) => {
224230 if ( ! secondStage ) {
225231 // Wait to settle 1 atemt to scroll
226- setTimeout ( ( ) => {
232+ pendingFirstStageTimeout = setTimeout ( ( ) => {
233+ pendingFirstStageTimeout = undefined
227234 let { top, bottom } = elementToScrollTo . getBoundingClientRect ( )
228235 top = Math . floor ( top )
229236 bottom = Math . floor ( bottom )
You can’t perform that action at this time.
0 commit comments