Skip to content

🎥 Make videos programmatically with React

fix(studio): keep frozen frame info inside sequence tracks

Jonny Burgerca37d8bfe5f3
diff --git a/packages/example/e2e/studio.test.mts b/packages/example/e2e/studio.test.mts
index 964ce8c89d..c13ae1ea96 100644
--- a/packages/example/e2e/studio.test.mts
+++ b/packages/example/e2e/studio.test.mts
@@ -429,6 +429,30 @@ test.describe('visual mode', () => {
'[data-timeline-sequence-frame]',
);
await expect(negativeSequenceFrame).toContainText('20');
+ await expect(negativeSequenceFrame.locator('svg')).toHaveCount(1);
+ const sequenceFrameIsClipped = () =>
+ negativeSequence.evaluate((element) => {
+ const frame = element.querySelector('[data-timeline-sequence-frame]');
+ if (!frame) {
+ return true;
+ }
+
+ const frameRight = frame.getBoundingClientRect().right;
+ let ancestor = frame.parentElement;
+ while (ancestor && ancestor !== element) {
+ const overflow = getComputedStyle(ancestor).overflow;
+ if (
+ (overflow === 'hidden' || overflow === 'clip') &&
+ ancestor.getBoundingClientRect().right < frameRight
+ ) {
+ return true;
+ }
+
+ ancestor = ancestor.parentElement;
+ }
+
+ return false;
+ });
const [
timelineRect,
@@ -458,30 +482,12 @@ test.describe('visual mode', () => {
(element) => getComputedStyle(element).overflow,
),
).toBe('visible');
- expect(
- await negativeSequence.evaluate((element) => {
- const frame = element.querySelector('[data-timeline-sequence-frame]');
- if (!frame) {
- return true;
- }
-
- const frameRight = frame.getBoundingClientRect().right;
- let ancestor = frame.parentElement;
- while (ancestor && ancestor !== element) {
- const overflow = getComputedStyle(ancestor).overflow;
- if (
- (overflow === 'hidden' || overflow === 'clip') &&
- ancestor.getBoundingClientRect().right < frameRight
- ) {
- return true;
- }
+ expect(await sequenceFrameIsClipped()).toBe(true);
- ancestor = ancestor.parentElement;
- }
-
- return false;
- }),
- ).toBe(false);
+ await page.getByRole('button', {name: 'Step forward one frame'}).click();
+ await expect(negativeSequenceFrame).toContainText('20');
+ await expect(negativeSequenceFrame.locator('svg')).toHaveCount(1);
+ expect(await sequenceFrameIsClipped()).toBe(true);
});
test('should commit a color drag before the picker closes', async ({
diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsx
index e2c8ffe6b4..30d687f117 100644
--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx
@@ -253,6 +253,8 @@ const TimelineSequenceCurrentFrame: React.FC<{
relativeFrameWithPostmount >= 0 &&
relativeFrameWithPostmount < (s.postmountDisplay ?? 0) &&
!isInRange;
+ const allowSequenceFrameOverflow =
+ frozenFrame === null && (isInRange || isPremounting || isPostmounting);
const negativeStartEnd = negativeStart
? negativeStart.left + negativeStart.width
: 0;
@@ -275,7 +277,7 @@ const TimelineSequenceCurrentFrame: React.FC<{
s.type !== 'video' &&
s.type !== 'image' &&
s.loopDisplay === undefined &&
- (isInRange || isPremounting || isPostmounting);
+ (frozenFrame !== null || allowSequenceFrameOverflow);
const sequenceFrameInfo = showSequenceFrame ? (
<div
data-timeline-sequence-frame
@@ -395,8 +397,21 @@ const TimelineSequenceCurrentFrame: React.FC<{
>
{content}
</div>
+ {sequenceFrameInfo && !allowSequenceFrameOverflow ? (
+ <div
+ style={{
+ height: '100%',
+ left: 5 + (premount?.width ?? 0),
+ pointerEvents: 'none',
+ position: 'absolute',
+ top: 0,
+ }}
+ >
+ {sequenceFrameInfo}
+ </div>
+ ) : null}
</div>
- {sequenceFrameInfo ? (
+ {sequenceFrameInfo && allowSequenceFrameOverflow ? (
<div
style={{
height: '100%',