Skip to content

Commit bec0fb3

Browse files
committed
feat: Improve timeline rendering logic
1 parent 608a547 commit bec0fb3

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

packages/webui/src/client/ui/SegmentTimeline/SegmentTimeline.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,11 @@ export class SegmentTimelineClass extends React.Component<Translated<WithTiming<
608608
private timelineStyle(outputGroups: IOutputLayerUi[]) {
609609
const showHiddenSourceLayers = getShowHiddenSourceLayers()
610610
const budgetDuration = this.getSegmentBudgetDuration()
611+
const scrollLeftPx = Math.round(this.convertTimeToPixels(this.props.scrollLeft))
611612

612613
return {
613614
willChange: this.props.isLiveSegment ? 'transform' : 'none',
614-
transform: 'translateX(-' + this.convertTimeToPixels(this.props.scrollLeft).toString() + 'px)',
615+
transform: `translate3d(-${scrollLeftPx}px, 0, 0)`,
615616
height: `calc(${outputGroups.reduce(
616617
(mem, group) =>
617618
mem +

packages/webui/src/client/ui/SegmentTimeline/SegmentTimelineContainer.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ const SegmentTimelineContainerContent = withResolvedSegment(
149149
intersectionObserver: IntersectionObserver | undefined
150150
mountedTime = 0
151151
nextPartOffset = 0
152+
liveLineRefreshFrame: number | undefined
153+
pendingLiveLineRefreshEvent: TimingEvent | undefined
152154

153155
constructor(props: IProps & ITrackedResolvedSegmentProps) {
154156
super(props)
@@ -354,6 +356,11 @@ const SegmentTimelineContainerContent = withResolvedSegment(
354356
}
355357

356358
this.stopLive()
359+
if (this.liveLineRefreshFrame !== undefined) {
360+
window.cancelAnimationFrame(this.liveLineRefreshFrame)
361+
this.liveLineRefreshFrame = undefined
362+
this.pendingLiveLineRefreshEvent = undefined
363+
}
357364
RundownViewEventBus.off(RundownViewEvents.REWIND_SEGMENTS, this.onRewindSegment)
358365
RundownViewEventBus.off(RundownViewEvents.GO_TO_PART, this.onGoToPart)
359366
RundownViewEventBus.off(RundownViewEvents.GO_TO_PART_INSTANCE, this.onGoToPartInstance)
@@ -491,7 +498,14 @@ const SegmentTimelineContainerContent = withResolvedSegment(
491498
}
492499
}
493500

494-
onAirLineRefresh = (e: TimingEvent) => {
501+
private flushAirLineRefresh = () => {
502+
this.liveLineRefreshFrame = undefined
503+
const event = this.pendingLiveLineRefreshEvent
504+
this.pendingLiveLineRefreshEvent = undefined
505+
if (event) this.applyAirLineRefresh(event)
506+
}
507+
508+
private applyAirLineRefresh = (e: TimingEvent) => {
495509
this.setState((state) => {
496510
if (state.isLiveSegment && state.currentLivePart) {
497511
const currentLivePartInstance = state.currentLivePart.instance
@@ -534,6 +548,12 @@ const SegmentTimelineContainerContent = withResolvedSegment(
534548
})
535549
}
536550

551+
onAirLineRefresh = (e: TimingEvent) => {
552+
this.pendingLiveLineRefreshEvent = e
553+
if (this.liveLineRefreshFrame !== undefined) return
554+
this.liveLineRefreshFrame = window.requestAnimationFrame(this.flushAirLineRefresh)
555+
}
556+
537557
visibleChanged = (entries: IntersectionObserverEntry[]) => {
538558
// Add a small debounce to ensure UI has settled before checking
539559
if (this.visibilityChangeTimeout) {

0 commit comments

Comments
 (0)