Create professional demos and 3D mockups in seconds, directly in your browser
feat: Improve zoom transition handling and scale calculations for movement-enabled fragments
CristianOlivera12b70669dc58b
diff --git a/app/components/ui/editor/VideoCanvas.tsx b/app/components/ui/editor/VideoCanvas.tsxindex 90df710..5cd9d0a 100644--- a/app/components/ui/editor/VideoCanvas.tsx+++ b/app/components/ui/editor/VideoCanvas.tsx@@ -296,12 +296,15 @@ function VideoCanvasInner({const translateX = 50 - phaseState.focusX;const translateY = 50 - phaseState.focusY;- // During hold phase with movement, reduce transition to avoid jarring+ const rawTransitionMs = speedToTransitionMs(activeZoomFragment.speed);+ const maxRampMs = ((activeZoomFragment.endTime - activeZoomFragment.startTime) / 2) * 1000;+ const clampedTransitionMs = Math.min(rawTransitionMs, maxRampMs);+const isMoving = activeZoomFragment.movementEnabled && phaseState.phase === 'hold';- const transitionMs = isMoving ? 50 : speedToTransitionMs(activeZoomFragment.speed);+ const transitionMs = isMoving ? 50 : clampedTransitionMs;return {- scale: phaseState.scale,+ scale: phaseState.phase === 'exit' ? 1 : phaseState.scale,translateX,translateY,transitionMs,diff --git a/types/zoom.types.ts b/types/zoom.types.tsindex 9852978..365a7ee 100644--- a/types/zoom.types.ts+++ b/types/zoom.types.ts@@ -133,12 +133,17 @@ export function calculateZoomPhaseState(const easedProgress = easeOutQuart(progress);if (forExport) {+scale = targetScale - (targetScale - 1) * easedProgress;- }-- if (fragment.movementEnabled) {- focusX = finalMovementPoint.x;- focusY = finalMovementPoint.y;+ if (fragment.movementEnabled) {+ focusX = finalMovementPoint.x;+ focusY = finalMovementPoint.y;+ }+ } else {++ scale = 1;+ focusX = 50;+ focusY = 50;}} else {