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} + + ) };