File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -347,6 +347,7 @@ export default function Page() {
347347 scroll : {
348348 overflow : false ,
349349 bottom : true ,
350+ jump : false ,
350351 } ,
351352 } )
352353
@@ -1247,13 +1248,17 @@ export default function Page() {
12471248 let scrollStateTarget : HTMLDivElement | undefined
12481249 let fillFrame : number | undefined
12491250
1251+ const jumpThreshold = ( el : HTMLDivElement ) => Math . max ( 400 , el . clientHeight )
1252+
12501253 const updateScrollState = ( el : HTMLDivElement ) => {
12511254 const max = el . scrollHeight - el . clientHeight
1255+ const distance = max - el . scrollTop
12521256 const overflow = max > 1
1253- const bottom = ! overflow || el . scrollTop >= max - 2
1257+ const bottom = ! overflow || distance <= 2
1258+ const jump = overflow && distance > jumpThreshold ( el )
12541259
1255- if ( ui . scroll . overflow === overflow && ui . scroll . bottom === bottom ) return
1256- setUi ( "scroll" , { overflow, bottom } )
1260+ if ( ui . scroll . overflow === overflow && ui . scroll . bottom === bottom && ui . scroll . jump === jump ) return
1261+ setUi ( "scroll" , { overflow, bottom, jump } )
12571262 }
12581263
12591264 const scheduleScrollState = ( el : HTMLDivElement ) => {
Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ export function MessageTimeline(props: {
200200 mobileChanges : boolean
201201 mobileFallback : JSX . Element
202202 actions ?: UserActions
203- scroll : { overflow : boolean ; bottom : boolean }
203+ scroll : { overflow : boolean ; bottom : boolean ; jump : boolean }
204204 onResumeScroll : ( ) => void
205205 setScrollRef : ( el : HTMLDivElement | undefined ) => void
206206 onScheduleScrollState : ( el : HTMLDivElement ) => void
@@ -568,10 +568,9 @@ export function MessageTimeline(props: {
568568 < div
569569 class = "absolute left-1/2 -translate-x-1/2 bottom-6 z-[60] pointer-events-none transition-all duration-200 ease-out"
570570 classList = { {
571- "opacity-100 translate-y-0 scale-100" :
572- props . scroll . overflow && ! props . scroll . bottom && ! staging . isStaging ( ) ,
571+ "opacity-100 translate-y-0 scale-100" : props . scroll . overflow && props . scroll . jump && ! staging . isStaging ( ) ,
573572 "opacity-0 translate-y-2 scale-95 pointer-events-none" :
574- ! props . scroll . overflow || props . scroll . bottom || staging . isStaging ( ) ,
573+ ! props . scroll . overflow || ! props . scroll . jump || staging . isStaging ( ) ,
575574 } }
576575 >
577576 < button
You can’t perform that action at this time.
0 commit comments