From 9d0dcc687f8f81c1b32b89485fd4fdd204ef7f86 Mon Sep 17 00:00:00 2001 From: Simon Hartcher Date: Tue, 16 May 2023 11:30:31 +1000 Subject: [PATCH] fix(loop): updated to use a single Sequence to fix video gaps when looping --- packages/core/src/loop/index.tsx | 37 +++++++++++++++----------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/packages/core/src/loop/index.tsx b/packages/core/src/loop/index.tsx index 103a03b8fd7..d6d0499a8cc 100644 --- a/packages/core/src/loop/index.tsx +++ b/packages/core/src/loop/index.tsx @@ -3,6 +3,7 @@ import type {LayoutAndStyle} from '../Sequence.js'; import {Sequence} from '../Sequence.js'; import {useVideoConfig} from '../use-video-config.js'; import {validateDurationInFrames} from '../validation/validate-duration-in-frames.js'; +import { useCurrentFrame } from '../use-current-frame.js'; export type LoopProps = { // The duration of the content to be looped @@ -24,7 +25,9 @@ export const Loop: React.FC = ({ name, ...props }) => { + const currentFrame = useCurrentFrame(); const {durationInFrames: compDuration} = useVideoConfig(); + validateDurationInFrames({ durationInFrames, component: 'of the component', @@ -52,26 +55,20 @@ export const Loop: React.FC = ({ const maxTimes = Math.ceil(compDuration / durationInFrames); const actualTimes = Math.min(maxTimes, times); const style = props.layout === 'none' ? undefined : props.style; + const maxFrame = durationInFrames * (actualTimes - 1); + const start = Math.floor(currentFrame / durationInFrames) * durationInFrames; return ( - <> - {new Array(actualTimes).fill(true).map((_, i) => { - return ( - - {children} - - ); - })} - - ); + + {children} + + ) };