File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
packages/webui/src/client/ui/SegmentTimeline Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ const SegmentTimelineContainerContent = withResolvedSegment(
145145 declare context : React . ContextType < typeof RundownTimingProviderContext >
146146
147147 isVisible : boolean
148+ visibilityChangeTimeout : NodeJS . Timeout | undefined
148149 rundownCurrentPartInstanceId : PartInstanceId | null = null
149150 timelineDiv : HTMLDivElement | null = null
150151 intersectionObserver : IntersectionObserver | undefined
@@ -535,12 +536,20 @@ const SegmentTimelineContainerContent = withResolvedSegment(
535536 }
536537
537538 visibleChanged = ( entries : IntersectionObserverEntry [ ] ) => {
538- if ( entries [ 0 ] . intersectionRatio < 0.99 && ! isMaintainingFocus ( ) && Date . now ( ) - this . mountedTime > 2000 ) {
539- if ( typeof this . props . onSegmentScroll === 'function' ) this . props . onSegmentScroll ( )
540- this . isVisible = false
541- } else {
542- this . isVisible = true
539+ // Add a small debounce to ensure UI has settled before checking
540+ if ( this . visibilityChangeTimeout ) {
541+ clearTimeout ( this . visibilityChangeTimeout )
543542 }
543+
544+ this . visibilityChangeTimeout = setTimeout ( ( ) => {
545+ if ( entries [ 0 ] . intersectionRatio < 0.99 && ! isMaintainingFocus ( ) && Date . now ( ) - this . mountedTime > 2000 ) {
546+ console . log ( 'Segment out of view :' , this . props . segmentId )
547+ if ( typeof this . props . onSegmentScroll === 'function' ) this . props . onSegmentScroll ( )
548+ this . isVisible = false
549+ } else {
550+ this . isVisible = true
551+ }
552+ } , 2000 )
544553 }
545554
546555 startLive = ( ) => {
You can’t perform that action at this time.
0 commit comments