@@ -673,7 +673,7 @@ export function getItemWithInteractions<
673673export function getCanvasBoundariesFromVisibleTime ( visibleTimeStart : number , visibleTimeEnd : number , buffer : number ) {
674674 const zoom = visibleTimeEnd - visibleTimeStart
675675 // buffer - 1 (1 is visible area) divided by 2 (2 is the buffer split on the right and left of the timeline)
676- const canvasTimeStart = visibleTimeStart - ( zoom * ( buffer - 1 ) ) / 2
676+ const canvasTimeStart = visibleTimeStart - zoom * ( buffer - 1 ) / 2
677677 const canvasTimeEnd = canvasTimeStart + zoom * buffer
678678 return [ canvasTimeStart , canvasTimeEnd ]
679679}
@@ -713,15 +713,16 @@ export function calculateScrollCanvas<
713713 visibleTimeEnd,
714714 }
715715
716+ // Calculate half of the buffer size on each side = 1/4 of the (buffer - viewport)
717+ const halfBuffer = oldZoom * ( buffer ! - 1 ) * 0.25
718+
716719 // Check if the current canvas covers the new times
717- const canKeepCanvas =
718- newZoom === oldZoom &&
719- visibleTimeStart >= oldCanvasTimeStart + oldZoom * 0.5 &&
720- visibleTimeStart <= oldCanvasTimeEnd - oldZoom * 1.5 &&
721- visibleTimeEnd >= oldCanvasTimeStart + oldZoom * 1.5 &&
722- visibleTimeEnd <= oldCanvasTimeEnd - oldZoom * 0.5
723-
724- if ( ! canKeepCanvas || forceUpdateDimensions ) {
720+ const shouldCreateNewCanvas =
721+ newZoom !== oldZoom ||
722+ visibleTimeStart <= oldCanvasTimeStart + halfBuffer ||
723+ visibleTimeEnd >= oldCanvasTimeEnd - halfBuffer
724+
725+ if ( shouldCreateNewCanvas || forceUpdateDimensions ) {
725726 const [ canvasTimeStart , canvasTimeEnd ] = getCanvasBoundariesFromVisibleTime (
726727 visibleTimeStart ,
727728 visibleTimeEnd ,
0 commit comments