Create professional demos and 3D mockups in seconds, directly in your browser
feat: enhance ToolsSidebar with selectedElementId and smooth scrolling
CristianOlivera16bc5e8f8931e
diff --git a/app/(editor)/editor/page.tsx b/app/(editor)/editor/page.tsxindex 65029a8..4acaf7d 100644--- a/app/(editor)/editor/page.tsx+++ b/app/(editor)/editor/page.tsx@@ -1374,7 +1374,7 @@ export default function Editor() {useEffect(() => {updateTimeSmoothRef.current = () => {if (justEndedRef.current) return;- if (isSwitchingClipRef.current) { // ← skip durante transición+ if (isSwitchingClipRef.current) {if (isPlaying && !isDraggingPlayhead) {animationFrameRef.current = requestAnimationFrame(updateTimeSmoothRef.current);}@@ -2023,6 +2023,7 @@ export default function Editor() {selectedZoomFragmentId={selectedZoomFragmentId}selectedAudioTrackId={selectedAudioTrackId}selectedVideoClipId={selectedVideoClipId}+ selectedElementId={selectedElementId}newVideosCount={newVideosCount}/></div>diff --git a/app/components/ui/FloatingCameraPreview.tsx b/app/components/ui/FloatingCameraPreview.tsxindex e089cc0..dd108f3 100644--- a/app/components/ui/FloatingCameraPreview.tsx+++ b/app/components/ui/FloatingCameraPreview.tsx@@ -11,16 +11,13 @@ interface Props {}function shapeRadius(shape: CameraConfig["shape"], size: number): string {- // Escala el radio base con el tamaño (20-60% → 0.5-1.5 multiplier)const sizeMultiplier = 0.5 + (size - 20) / 40;if (shape === "circle") return "50%";if (shape === "squircle") {- // Base ~20px, escalado dinámicamenteconst baseRadiusPx = 20;return `${Math.round(baseRadiusPx * sizeMultiplier)}px`;}- // Square: base 6px para esquinas ligeramente redondeadasconst baseRadiusPx = 6;return `${Math.round(baseRadiusPx * sizeMultiplier)}px`;}@@ -93,7 +90,8 @@ export default function FloatingCameraPreview({ stream, config, onConfigChange }typeof window !== "undefined" ? window.innerWidth : 1920,typeof window !== "undefined" ? window.innerHeight : 1080);- const radius = shapeRadius(config.shape, config.size);+ const isSquircle = config.shape === "squircle";+ const radius = shapeRadius(config.shape, config.size * 100);return (<div@@ -102,7 +100,7 @@ export default function FloatingCameraPreview({ stream, config, onConfigChange }onPointerMove={onPointerMove}onPointerUp={onPointerUp}onPointerCancel={onPointerUp}- className={`fixed pointer-events-auto select-none z-[60] group ${+ className={`fixed pointer-events-auto select-none z-60 group ${isDragging ? "cursor-grabbing" : "cursor-grab"}`}style={{@@ -121,7 +119,7 @@ export default function FloatingCameraPreview({ stream, config, onConfigChange }mutedplaysInlineclassName={`size-full object-cover shadow-[0_10px_40px_rgba(0,0,0,0.55)] ring-1 ring-white/20 ${- config.shape === "squircle" ? "squircle-element" : ""+ isSquircle ? "squircle-element-camera" : ""}`}style={{borderRadius: radius,@@ -130,16 +128,16 @@ export default function FloatingCameraPreview({ stream, config, onConfigChange }/><div- className={`pointer-events-none absolute inset-0 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center bg-black/30 ${- config.shape === "squircle" ? "squircle-element" : ""- }`}- style={{ borderRadius: radius }}+ className="pointer-events-none absolute inset-0 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center bg-black/30"+ style={{+ borderRadius: radius,+ }}>- <div className="flex items-center gap-1.5 px-2 py-1 rounded-full bg-black/60 text-white text-[10px] font-medium">- <Icon icon="solar:hand-move-bold" className="size-3.5" />- Arrastrar- </div>+ <div className="flex items-center gap-1.5 px-2 py-1 rounded-full bg-black/60 text-white text-[10px] font-medium">+ <Icon icon="solar:hand-move-bold" className="size-3.5" />+ Arrastrar</div></div>- );+ </div>+);}diff --git a/app/components/ui/RecordingSetupDialog.tsx b/app/components/ui/RecordingSetupDialog.tsxindex ce52d9a..a68cc89 100644--- a/app/components/ui/RecordingSetupDialog.tsx+++ b/app/components/ui/RecordingSetupDialog.tsx@@ -396,13 +396,13 @@ export default function RecordingSetupDialog({ open, onClose, onStart }: Props)autoPlaymutedplaysInline- className={`size-full object-cover border-2 border-white/20 shadow-[0_8px_40px_rgba(0,163,255,0.25)] transition-all duration-300 ${setup.camera.shape === "squircle" ? "squircle-element-camara" : ""+ className={`size-full object-cover border-2 border-white/20 shadow-[0_8px_40px_rgba(0,163,255,0.25)] transition-all duration-300 ${setup.camera.shape === "squircle" ? "squircle-element-camera" : ""}`}style={previewFrameStyle}/>) : (<div- className={`size-full flex items-center justify-center border-2 border-dashed border-white/20 text-neutral-500 transition-all duration-300 ${setup.camera.shape === "squircle" ? "squircle-element-camara" : ""+ className={`size-full flex items-center justify-center border-2 border-dashed border-white/20 text-neutral-500 transition-all duration-300 ${setup.camera.shape === "squircle" ? "squircle-element-camera" : ""}`}style={previewFrameStyle}>diff --git a/app/components/ui/editor/ElementsMenu.tsx b/app/components/ui/editor/ElementsMenu.tsxindex 42956c2..a72ae1b 100644--- a/app/components/ui/editor/ElementsMenu.tsx+++ b/app/components/ui/editor/ElementsMenu.tsx@@ -11,6 +11,17 @@ import { Button } from "@/components/ui/button";import { SVG_COMPONENTS } from "@/components/canvas-svg";import { TooltipAction } from "@/components/ui/tooltip-action";+interface UploadedImage {+ id: string;+ name: string;+ dataUrl: string;+ uploadedAt: number;+}++const STORAGE_KEY = "openvid-uploaded-images";+const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB+const ACCEPTED_FORMATS = ["image/png", "image/jpeg", "image/jpg", "image/webp", "image/gif"];+export function ElementsMenu({onAddElement,selectedElement,@@ -19,7 +30,7 @@ export function ElementsMenu({onBringToFront,onSendToBack}: ElementsMenuProps) {- const [mode, setMode] = useState<"text" | "elements">("elements");+ const [mode, setMode] = useState<"text" | "elements" | "uploads">("elements");// Professional default values for elementsconst [shapeSize, setShapeSize] = useState(20);@@ -39,6 +50,20 @@ export function ElementsMenu({const [selectedSvgCategory, setSelectedSvgCategory] = useState<string>("all");const [selectedImageCategory, setSelectedImageCategory] = useState<string>("all");+ const [uploadedImages, setUploadedImages] = useState<UploadedImage[]>(() => {+ // Load from localStorage on initial mount+ try {+ const stored = localStorage.getItem(STORAGE_KEY);+ if (stored) {+ return JSON.parse(stored) as UploadedImage[];+ }+ } catch (error) {+ console.error("Error loading uploaded images:", error);+ }+ return [];+ });+ const [isUploading, setIsUploading] = useState(false);+const isSyncing = useRef(false);const lastSelectedId = useRef<string | null>(null);@@ -122,6 +147,132 @@ export function ElementsMenu({}}, [textContent, textFontSize, textColor, textOpacity, textFontFamily, textFontWeight, selectedElement?.id, selectedElement?.type, onUpdateElement]);+ // Save uploaded images to localStorage whenever they change+ useEffect(() => {+ if (uploadedImages.length > 0) {+ try {+ localStorage.setItem(STORAGE_KEY, JSON.stringify(uploadedImages));+ } catch (error) {+ console.error("Error saving uploaded images:", error);+ }+ } else {+ // Remove from localStorage if no images+ localStorage.removeItem(STORAGE_KEY);+ }+ }, [uploadedImages]);++ // Handler to upload images and auto-add to canvas+ const handleImageUpload = useCallback(async (files: FileList | null) => {+ if (!files || files.length === 0) return;++ setIsUploading(true);+ const newImages: UploadedImage[] = [];++ for (let i = 0; i < files.length; i++) {+ const file = files[i];++ // Validate file type+ if (!ACCEPTED_FORMATS.includes(file.type)) {+ console.warn(`Formato no soportado: ${file.type}`);+ continue;+ }++ // Validate file size+ if (file.size > MAX_FILE_SIZE) {+ console.warn(`Archivo muy grande: ${file.name} (${(file.size / 1024 / 1024).toFixed(2)}MB)`);+ continue;+ }++ try {+ // Convert to base64 data URL+ const dataUrl = await new Promise<string>((resolve, reject) => {+ const reader = new FileReader();+ reader.onload = () => resolve(reader.result as string);+ reader.onerror = reject;+ reader.readAsDataURL(file);+ });++ const uploadedImage: UploadedImage = {+ id: `upload-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`,+ name: file.name,+ dataUrl,+ uploadedAt: Date.now(),+ };++ newImages.push(uploadedImage);++ // Auto-add to canvas immediately+ const timestamp = Date.now() + i; // Offset to ensure unique zIndex+ const newElement: ImageElement = {+ id: `image-${timestamp}-${Math.random().toString(36).substring(2, 9)}`,+ type: "image",+ category: "uploads",+ x: 50,+ y: 50,+ width: imageSize,+ height: imageSize,+ rotation: 0,+ opacity: imageOpacity / 100,+ zIndex: timestamp,+ imagePath: dataUrl,+ };+ onAddElement(newElement);+ } catch (error) {+ console.error(`Error uploading ${file.name}:`, error);+ }+ }++ if (newImages.length > 0) {+ setUploadedImages(prev => [...prev, ...newImages]);+ }++ setIsUploading(false);+ }, [imageSize, imageOpacity, onAddElement]);++ // Handler to delete an uploaded image+ const handleDeleteUploadedImage = useCallback((id: string) => {+ setUploadedImages(prev => {+ const filtered = prev.filter(img => img.id !== id);+ // Clear localStorage if no images left+ if (filtered.length === 0) {+ localStorage.removeItem(STORAGE_KEY);+ }+ return filtered;+ });+ }, []);++ // Handler to manually add uploaded image to canvas (from gallery)+ const handleAddUploadedImage = useCallback((image: UploadedImage) => {+ const timestamp = Date.now();+ const newElement: ImageElement = {+ id: `image-${timestamp}-${Math.random().toString(36).substring(2, 9)}`,+ type: "image",+ category: "uploads",+ x: 50,+ y: 50,+ width: imageSize,+ height: imageSize,+ rotation: 0,+ opacity: imageOpacity / 100,+ zIndex: timestamp,+ imagePath: image.dataUrl,+ };+ onAddElement(newElement);+ }, [imageSize, imageOpacity, onAddElement]);++ // Drag & drop handlers+ const handleDragOver = useCallback((e: React.DragEvent<HTMLLabelElement>) => {+ e.preventDefault();+ e.stopPropagation();+ }, []);++ const handleDrop = useCallback((e: React.DragEvent<HTMLLabelElement>) => {+ e.preventDefault();+ e.stopPropagation();+ const files = e.dataTransfer.files;+ handleImageUpload(files);+ }, [handleImageUpload]);+const filteredSvgItems = selectedSvgCategory === "all"? SVG_CATEGORIES.flatMap(cat => cat.items.map(item => ({ ...item, category: cat.id }))): SVG_CATEGORIES.find(cat => cat.id === selectedSvgCategory)?.items.map(item => ({ ...item, category: selectedSvgCategory })) || [];@@ -197,7 +348,7 @@ export function ElementsMenu({<span>Elementos</span></div>- <div className="grid grid-cols-2 bg-[#09090B] squircle-element p-1 text-xs font-medium border border-white/5">+ <div className="grid grid-cols-3 bg-[#09090B] squircle-element p-1 text-xs font-medium border border-white/5"><buttonclassName={`flex justify-center items-center gap-1.5 py-1.5 rounded transition ${mode === "elements" ? "bg-white/10 text-white" : "text-white/50 hover:text-white/80"}`}onClick={() => setMode("elements")}@@ -212,6 +363,14 @@ export function ElementsMenu({<Icon icon="iconoir:text-size" width="14" />Texto</button>++ <button+ className={`flex justify-center items-center gap-1.5 py-1.5 rounded transition ${mode === "uploads" ? "bg-white/10 text-white" : "text-white/50 hover:text-white/80"}`}+ onClick={() => setMode("uploads")}+ >+ <Icon icon="ph:upload-simple-bold" width="14" />+ Cargar+ </button></div>{mode === "elements" && (@@ -722,9 +881,114 @@ export function ElementsMenu({)}</div>)}++ {mode === "uploads" && (+ <div className="flex flex-col gap-5 animate-in fade-in duration-150">+ <div className="space-y-2">+ <div className="text-[10px] uppercase tracking-widest text-white/40 font-semibold">+ Subir imágenes+ </div>++ <label+ className={`group flex flex-col items-center justify-center w-full bg-[#09090B] border border-dashed border-white/10 hover:border-white/30 hover:bg-white/3 squircle-element p-8 text-center cursor-pointer transition-all ${isUploading ? 'opacity-50 pointer-events-none' : ''}`}+ onDragOver={handleDragOver}+ onDrop={handleDrop}+ >+ {isUploading ? (+ <div className="flex flex-col items-center justify-center w-full">+ <div className="w-12 h-12 rounded-full bg-white/5 border border-white/10 flex items-center justify-center mx-auto mb-4 transition-transform">+ <Icon icon="svg-spinners:180-ring-with-bg" width="24" className="text-white/50" />+ </div>+ <p className="text-sm font-medium text-white/70 mb-1">Subiendo...</p>+ <p className="text-xs text-white/40">Procesando imágenes</p>+ </div>+ ) : (+ <div className="flex flex-col items-center justify-center w-full">+ <div className="w-12 h-12 rounded-full bg-white/5 border border-white/10 flex items-center justify-center mx-auto mb-4 group-hover:scale-105 transition-transform">+ <Icon icon="solar:upload-minimalistic-outline" width="24" className="text-white/40 group-hover:text-white/70 transition-colors" />+ </div>+ <p className="text-sm font-medium text-white/70 mb-1">Subir imágenes</p>+ <p className="text-xs text-white/40 mb-5">Haz clic o arrastra un archivo aquí</p>++ <div className="inline-flex items-center justify-center gap-2 whitespace-nowrap squircle-element font-medium transition-all border border-white/10 bg-transparent hover:bg-white/10 h-9 px-4 py-2 w-full text-xs text-white/70 group-hover:text-white shadow-xs">+ <span>Seleccionar archivo</span>+ </div>+ </div>+ )}++ <input+ type="file"+ className="hidden"+ accept="image/png,image/jpeg,image/jpg,image/webp,image/gif"+ multiple+ onChange={(e) => handleImageUpload(e.target.files)}+ disabled={isUploading}+ />+ </label>+ </div>++ <div className="space-y-2">+ <div className="flex justify-between items-center">+ <div className="text-[10px] uppercase tracking-widest text-white/40 font-semibold">+ Tus imágenes ({uploadedImages.length})+ </div>+ {uploadedImages.length > 0 && (+ <button+ onClick={() => {+ setUploadedImages([]);+ localStorage.removeItem(STORAGE_KEY);+ }}+ className="text-[10px] text-red-400/70 hover:text-red-400 transition-colors"+ >+ Limpiar todo+ </button>+ )}+ </div>+ <div className="grid grid-cols-3 gap-2">+ {uploadedImages.length === 0 ? (+ <div className="col-span-3 py-10 flex flex-col items-center justify-center text-center bg-[#09090B] border border-dashed border-white/10 squircle-element">+ <div className="w-10 h-10 rounded-full bg-white/5 border border-white/10 flex items-center justify-center mb-3">+ <Icon icon="mynaui:image" width="20" className="text-white/40" />+ </div>+ <span className="text-xs font-medium text-white/60 mb-0.5">Aún no hay imágenes</span>+ <span className="text-[10px] text-white/40">Las imágenes que subas aparecerán aquí</span>+ </div>+ ) : (+ uploadedImages.map((image) => (+ <div+ key={image.id}+ className="group relative aspect-square rounded-lg overflow-hidden border border-white/10 bg-white/5 hover:border-white/30 transition-all cursor-pointer"+ onClick={() => handleAddUploadedImage(image)}+ title={`${image.name}\nHaz clic para agregar otra vez al canvas`}+ >+ <img+ src={image.dataUrl}+ alt={image.name}+ className="w-full h-full object-cover"+ />+ <div className="absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center">+ <Icon icon="ph:plus-circle-bold" width="24" className="text-white" />+ </div>+ <button+ onClick={(e) => {+ e.stopPropagation();+ handleDeleteUploadedImage(image.id);+ }}+ className="absolute top-1 right-1 p-1 rounded bg-black/60 hover:bg-red-500/80 text-white/70 hover:text-white opacity-0 group-hover:opacity-100 transition-all z-10"+ >+ <Icon icon="ph:trash-bold" width="12" />+ </button>+ </div>+ ))+ )}+ </div>+ </div>+ </div>+ )}</div>);}+function ProgressiveImg({src,alt,diff --git a/app/components/ui/editor/ToolsSidebar.tsx b/app/components/ui/editor/ToolsSidebar.tsxindex 3555502..38c6f42 100644--- a/app/components/ui/editor/ToolsSidebar.tsx+++ b/app/components/ui/editor/ToolsSidebar.tsx@@ -15,6 +15,7 @@ interface ExtendedToolsSidebarProps extends ToolsSidebarProps {selectedZoomFragmentId?: string | null;selectedAudioTrackId?: string | null;selectedVideoClipId?: string | null;+ selectedElementId?: string | null;newVideosCount?: number;}@@ -27,6 +28,7 @@ export function ToolsSidebar({selectedZoomFragmentId,selectedAudioTrackId,selectedVideoClipId,+ selectedElementId,newVideosCount = 0,}: ExtendedToolsSidebarProps) {const fileInputRef = useRef<HTMLInputElement>(null);@@ -34,6 +36,7 @@ export function ToolsSidebar({const audioToolRef = useRef<HTMLButtonElement>(null);const videosToolRef = useRef<HTMLButtonElement>(null);const cameraToolRef = useRef<HTMLButtonElement>(null);+ const elementsToolRef = useRef<HTMLButtonElement>(null);const [isDragging, setIsDragging] = useState(false);const { startCountdown, isIdle, isRecording, isCountdown, isProcessing } = useRecording();const [showMobileAlert, setShowMobileAlert] = useState(false);@@ -70,6 +73,12 @@ export function ToolsSidebar({}}, [activeTool]);+ useEffect(() => {+ if (selectedElementId && elementsToolRef.current) {+ elementsToolRef.current.scrollIntoView({ behavior: 'smooth', block: 'center' });+ }+ }, [selectedElementId]);+const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {const file = e.target.files?.[0];if (file && onVideoUpload) {@@ -190,6 +199,7 @@ export function ToolsSidebar({label="Elementos"isActive={activeTool === "elements"}onClick={() => onToolChange("elements")}+ ref={elementsToolRef}icon={<svgwidth="24"diff --git a/app/components/ui/editor/VideoCanvas.tsx b/app/components/ui/editor/VideoCanvas.tsxindex 67b7dea..6bdb184 100644--- a/app/components/ui/editor/VideoCanvas.tsx+++ b/app/components/ui/editor/VideoCanvas.tsx@@ -1,12 +1,10 @@"use client";-import { useRef, useEffect, useImperativeHandle, forwardRef, useMemo, useState, useCallback } from "react";+import { useRef, useEffect, useImperativeHandle, forwardRef, useMemo, useState } from "react";import type { VideoCanvasHandle, VideoCanvasProps, VideoThumbnail } from "@/types";import type { ImageElement, SvgElement, CanvasElement } from "@/types/canvas-elements.types";import { getCameraLayout } from "@/types/camera.types";import { ASPECT_RATIO_DIMENSIONS } from "@/types";-// import { interpolateCursorPosition, DEFAULT_CURSOR_CONFIG, EMPTY_CURSOR_DATA } from "@/types/cursor.types";-// import type { CursorKeyframe } from "@/types/cursor.types";import { getWallpaperUrl } from "@/lib/wallpaper.utils";import { drawRoundedRect, drawRoundedRectBottomOnly, calculateScaledPadding, applyCanvasBackground, getAspectRatioStyle, getMaxWidth, Corner, getCornerStyle, getNearestCorner } from "@/lib/canvas.utils";import { drawMockupToCanvas } from "@/lib/mockup-canvas.utils";@@ -16,8 +14,7 @@ import PlaceholderEditor from "../PlaceholderEditor";import { MockupWrapper } from "./mockups/MockupWrapper";import { DEFAULT_MOCKUP_CONFIG } from "@/types/mockup.types";import { calculateSmoothZoom } from "@/lib/canvas.utils";-import { SVG_COMPONENTS, getSvgDataUrl } from "@/components/canvas-svg";-// import { getCursorSvgDataUrl } from "@/components/cursor-svg";+import { getSvgDataUrl } from "@/components/canvas-svg";import { VIDEO_Z_INDEX, BOTTOM_ONLY_RADIUS_MOCKUPS, SELF_SHADOWING_MOCKUPS } from "@/lib/constants";import { RotationHandleIcon } from "@/components/ui/RotationHandleIcon";import { CanvasElementsLayer } from "./CanvasElementsLayer";@@ -56,10 +53,6 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functselectedElementId = null,onElementUpdate,onElementSelect,- // Cursor props- // cursorConfig = DEFAULT_CURSOR_CONFIG,- // cursorData = EMPTY_CURSOR_DATA,- // Camera overlay propscameraUrl = null,cameraConfig = null,onCameraConfigChange,@@ -82,7 +75,6 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct// Calculate zoom transform for visual preview using 3-phase system// Phase 1: Entry (zoom in), Phase 2: Hold with optional movement, Phase 3: Exit (zoom out)const zoomTransform = useMemo(() => {- // No active fragment - smooth exit to base scaleif (!activeZoomFragment) {const lastFragment = zoomFragments.filter(f => f.endTime < currentTime)@@ -108,7 +100,6 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functconst translateY = (50 - phaseState.focusY) * (phaseState.scale - 1) * 2;// During hold phase with movement, reduce transition to avoid jarring- // CSS transitions should only apply to scale (entry/exit), not translate during movementconst isMoving = activeZoomFragment.movementEnabled && phaseState.phase === 'hold';const transitionMs = isMoving ? 50 : speedToTransitionMs(activeZoomFragment.speed);@@ -124,34 +115,6 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct};}, [activeZoomFragment, zoomFragments, currentTime]);- // Calculate current cursor position from cursor data- /*const cursorPosition = useMemo<CursorKeyframe | null>(() => {- if (!cursorConfig.visible || cursorConfig.style === "none" || !cursorData.hasCursorData) {- return null;- }- return interpolateCursorPosition(cursorData.keyframes, currentTime, cursorConfig.smoothing);- }, [cursorConfig.visible, cursorConfig.style, cursorConfig.smoothing, cursorData.hasCursorData, cursorData.keyframes, currentTime]);*/-- // Get cursor SVG data URL for rendering- /*const cursorSvgDataUrl = useMemo(() => {- if (!cursorPosition || cursorConfig.style === "none") return null;- return getCursorSvgDataUrl(cursorConfig.style, cursorPosition.state, cursorConfig.color, cursorConfig.size);- }, [cursorPosition, cursorConfig.style, cursorConfig.color, cursorConfig.size]);*/-- // Preload cursor image for canvas rendering- /* const cursorImageRef = useRef<HTMLImageElement | null>(null);- useEffect(() => {- if (cursorSvgDataUrl) {- const img = new Image();- img.src = cursorSvgDataUrl;- img.onload = () => {- cursorImageRef.current = img;- };- } else {- cursorImageRef.current = null;- }- }, [cursorSvgDataUrl]);*/-// Determinar qué background mostrar basado en el tab activoconst shouldShowUnsplashOverride = backgroundTab === "wallpaper" && unsplashOverrideUrl !== "";const shouldShowWallpaper = backgroundTab === "wallpaper" && selectedWallpaper >= 0 && !shouldShowUnsplashOverride;@@ -174,14 +137,12 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functreturn dims || { width: 1920, height: 1080 };}, [aspectRatio, customAspectRatio]);- // On-canvas controls stateconst [isVideoHovered, setIsVideoHovered] = useState(false);// Set initial video src when videoUrl changes (initial load only — transitions manage src imperatively)const lastSetVideoUrlRef = useRef<string | null>(null);useEffect(() => {if (videoRef.current && videoUrl && videoUrl !== lastSetVideoUrlRef.current) {- // Only set src if video element has no src or src is emptyif (!videoRef.current.src || videoRef.current.src === '' || videoRef.current.src === window.location.href) {videoRef.current.src = videoUrl;lastSetVideoUrlRef.current = videoUrl;@@ -222,8 +183,6 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functconst elementImagesRef = useRef<Map<string, HTMLImageElement>>(new Map());// SVG element image cache keyed by "svgId-color" — avoids new Image() per frameconst svgImageCacheRef = useRef<Map<string, HTMLImageElement>>(new Map());- // Cursor image cache keyed by data URL — avoids new Image() + decode per frame- // const cursorImageCacheRef = useRef<Map<string, HTMLImageElement>>(new Map());// Actualizar canvas dimensions cuando cambia el aspect ratiouseEffect(() => {@@ -665,7 +624,6 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functconst backgroundImage = (shouldShowCustomImage || shouldShowUnsplashOverride) ? customImageRef.current : (shouldShowWallpaper ? wallpaperImageRef.current : null);- // 1. Dibujar fondoif (shouldShowCustomColor && backgroundColorCss) {applyCanvasBackground(ctx, backgroundColorCss, canvasWidth, canvasHeight);} else if (backgroundImage) {@@ -688,10 +646,8 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functctx.restore();}- // 2. Render elements BEHIND video (zIndex < VIDEO_Z_INDEX) - before video transformawait renderCanvasElements(ctx, canvasElements, canvasWidth, canvasHeight, true);- // 3. Calcular área disponible para el mockup/videoconst availableWidth = canvasWidth - scaledPaddingX * 2;const availableHeight = canvasHeight - scaledPaddingY * 2;@@ -820,85 +776,6 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct// 8. Render elements ABOVE video (zIndex >= VIDEO_Z_INDEX)await renderCanvasElements(ctx, canvasElements, canvasWidth, canvasHeight, false);- // 9. Render cursor overlay if enabled and data available- /* if (cursorConfig.visible && cursorConfig.style !== "none" && cursorData.hasCursorData) {- const frameTime = video.currentTime;- const cursorPos = interpolateCursorPosition(cursorData.keyframes, frameTime, cursorConfig.smoothing);-- if (cursorPos) {- // Get cursor image from cache- const cursorDataUrl = getCursorSvgDataUrl(cursorConfig.style, cursorPos.state, cursorConfig.color, cursorConfig.size);- if (cursorDataUrl) {- let cursorImg = cursorImageCacheRef.current.get(cursorDataUrl);- if (!cursorImg) {- cursorImg = new Image();- cursorImageCacheRef.current.set(cursorDataUrl, cursorImg);- cursorImg.src = cursorDataUrl;- await new Promise<void>((resolve) => {- if (cursorImg!.complete) resolve();- else { cursorImg!.onload = () => resolve(); cursorImg!.onerror = () => resolve(); }- });- } else if (!cursorImg.complete) {- await new Promise<void>((resolve) => {- cursorImg!.onload = () => resolve();- cursorImg!.onerror = () => resolve();- setTimeout(resolve, 500);- });- }-- // Calculate cursor position relative to the video area- // The cursor positions stored are percentages of the video dimensions- const cursorX = videoX + (cursorPos.x / 100) * videoWidth;- const cursorY = videoY + (cursorPos.y / 100) * videoHeight;-- // Scale cursor size based on canvas dimensions- const cursorScale = canvasWidth / 1920; // Reference 1920px- const scaledCursorSize = cursorConfig.size * cursorScale;-- ctx.save();- ctx.globalAlpha = 1;-- // Draw click effect if clicking- if (cursorPos.clicking && cursorConfig.clickEffect !== "none") {- ctx.save();- const effectSize = scaledCursorSize * 2;-- if (cursorConfig.clickEffect === "ripple") {- // Ripple effect - expanding circles- ctx.beginPath();- ctx.arc(cursorX, cursorY, effectSize, 0, Math.PI * 2);- ctx.strokeStyle = cursorConfig.clickEffectColor;- ctx.lineWidth = 3 * cursorScale;- ctx.globalAlpha = 0.5;- ctx.stroke();- } else if (cursorConfig.clickEffect === "ring") {- // Ring effect - solid ring- ctx.beginPath();- ctx.arc(cursorX, cursorY, effectSize * 0.8, 0, Math.PI * 2);- ctx.strokeStyle = cursorConfig.clickEffectColor;- ctx.lineWidth = 4 * cursorScale;- ctx.globalAlpha = 0.7;- ctx.stroke();- }-- ctx.restore();- }-- // Draw cursor image- // Cursor hotspot is typically at top-left for arrow cursors- ctx.drawImage(- cursorImg,- cursorX,- cursorY,- scaledCursorSize,- scaledCursorSize- );-- ctx.restore();- }- }- }*/-ctx.restore();// 10. Camera overlay — drawn in screen space AFTER zoom transform is unwound,@@ -907,7 +784,6 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct};// Draw the camera bubble in screen-space coordinates.- // Runs after the zoom ctx.restore() so position/size are unaffected by zoom.const drawCameraOverlay = async (ctx: CanvasRenderingContext2D,canvasWidth: number,@@ -915,72 +791,104 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct) => {const camVideo = cameraVideoRef.current;const mainVideo = videoRef.current;+if (!camVideo || !cameraConfig || !cameraConfig.enabled) return;- if (camVideo.readyState < 2 || !camVideo.videoWidth || !camVideo.videoHeight) return;-- // During export, main video seeks frame-by-frame; event-driven sync can leave the- // camera one frame behind. Nudge the camera to the main video's time and await- // the resulting seek so drawImage picks up the correct frame.- if (mainVideo && Math.abs(camVideo.currentTime - mainVideo.currentTime) > 0.05) {- try {- camVideo.currentTime = mainVideo.currentTime;- await new Promise<void>((resolve) => {- const done = () => {- camVideo.removeEventListener("seeked", done);- resolve();- };- camVideo.addEventListener("seeked", done);- // Guard against events that never fire (e.g., paused camera at end)- setTimeout(() => {- camVideo.removeEventListener("seeked", done);- resolve();- }, 150);- });- } catch {- // continue with whatever frame is available++ if (!camVideo.videoWidth || !camVideo.videoHeight) return;++ if (mainVideo && camVideo.duration > 0 && mainVideo.currentTime > camVideo.duration - 0.1) return;++ if (mainVideo && camVideo.paused) {+ const diff = Math.abs(camVideo.currentTime - mainVideo.currentTime);++ if (diff > 0.05) {+ try {+ const targetTime = Math.min(+ mainVideo.currentTime,+ camVideo.duration - 0.05+ );+ camVideo.currentTime = targetTime;++ // Esperar seeked + readyState+ await new Promise<void>((resolve) => {+ const fallbackTimeout = setTimeout(() => {+ camVideo.removeEventListener("seeked", onSeeked);+ resolve();+ }, 400);++ const onSeeked = () => {+ camVideo.removeEventListener("seeked", onSeeked);++ const checkReady = setInterval(() => {+ if (camVideo.readyState >= 3) {+ clearInterval(checkReady);+ clearTimeout(fallbackTimeout);+ resolve();+ }+ }, 10);+ };++ camVideo.addEventListener("seeked", onSeeked);+ });+ } catch {+ // continuar con el frame disponible+ }}}+ if (camVideo.readyState < 2) return;+const { size, left: drawX, top: drawY } = getCameraLayout(cameraConfig,canvasWidth,canvasHeight);+if (size <= 0) return;- const shortSide = Math.min(canvasWidth, canvasHeight);- // Escala el radio dinámicamente (igual que en preview)- const sizePercent = cameraConfig.size * 100; // 0.18 → 18+ const shortSide = Math.min(canvasWidth, canvasHeight);+ const sizePercent = cameraConfig.size * 100;const sizeMultiplier = 0.5 + (sizePercent - 20) / 40;-- const radius =- cameraConfig.shape === "circle"- ? size / 2- : cameraConfig.shape === "squircle"- ? Math.round(22 * sizeMultiplier)- : Math.round(4 * sizeMultiplier);-- // Center-crop the camera frame to a squareconst srcShort = Math.min(camVideo.videoWidth, camVideo.videoHeight);const sx = (camVideo.videoWidth - srcShort) / 2;const sy = (camVideo.videoHeight - srcShort) / 2;ctx.save();-- // Drop shadow to match preview stylingctx.shadowColor = "rgba(0, 0, 0, 0.55)";ctx.shadowBlur = shortSide * 0.02;ctx.shadowOffsetY = shortSide * 0.008;- drawRoundedRect(ctx, drawX, drawY, size, size, radius);- ctx.fill();+ if (cameraConfig.shape === "circle") {+ const centerX = drawX + size / 2;+ const centerY = drawY + size / 2;+ const radius = size / 2;++ ctx.beginPath();+ ctx.arc(centerX, centerY, radius, 0, Math.PI * 2);+ ctx.fill();++ ctx.shadowColor = "transparent";+ ctx.shadowBlur = 0;+ ctx.shadowOffsetY = 0;- ctx.shadowColor = "transparent";- ctx.shadowBlur = 0;- ctx.shadowOffsetY = 0;+ ctx.beginPath();+ ctx.arc(centerX, centerY, radius, 0, Math.PI * 2);+ ctx.clip();+ } else {+ const radius = cameraConfig.shape === "squircle"+ ? Math.round(80 * sizeMultiplier)+ : Math.round(6 * sizeMultiplier);- drawRoundedRect(ctx, drawX, drawY, size, size, radius);- ctx.clip();+ drawRoundedRect(ctx, drawX, drawY, size, size, radius);+ ctx.fill();++ ctx.shadowColor = "transparent";+ ctx.shadowBlur = 0;+ ctx.shadowOffsetY = 0;++ drawRoundedRect(ctx, drawX, drawY, size, size, radius);+ ctx.clip();+ }if (cameraConfig.mirror) {ctx.translate(drawX + size, drawY);@@ -993,7 +901,6 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functctx.restore();};- // Exponer métodos para exportaciónuseImperativeHandle(ref, () => ({getExportCanvas: () => exportCanvasRef.current,drawFrame,@@ -1043,7 +950,7 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functtransition: zoomTransform.isMoving? `transform ${zoomTransform.transitionMs}ms linear`: `transform ${zoomTransform.transitionMs}ms ${ZOOM_EASING}`,- transformStyle: 'preserve-3d', // ← mover aquí desde el div hijo+ transformStyle: 'preserve-3d',}}>{/* 3D rotation layer */}@@ -1054,7 +961,6 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct? `rotateX(${zoomTransform.rotateX}deg) rotateY(${zoomTransform.rotateY}deg)`: 'none',transition: `transform ${zoomTransform.transitionMs}ms ${ZOOM_EASING}`,- // ← quitar transformStyle de aquí}}>{/* Capa 1: Fondo (siempre llena todo el contenedor) */}@@ -1066,19 +972,19 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functstyle={{inset: backgroundBlur > 0 ? `-${backgroundBlur}px` : '0',...(shouldShowCustomColor && backgroundColorCss- ? // Color sólido o gradiente CSS+ ?backgroundColorCss.startsWith('#') || backgroundColorCss.startsWith('rgb')? { backgroundColor: backgroundColorCss }: { backgroundImage: backgroundColorCss }: (shouldShowCustomImage || shouldShowUnsplashOverride)- ? // Imagen personalizada o Unsplash override+ ?{backgroundImage: `url('${shouldShowCustomImage ? selectedImageUrl : unsplashOverrideUrl}')`,backgroundSize: 'cover',backgroundPosition: 'center',}: shouldShowWallpaper- ? // Wallpaper+ ?{backgroundImage: `url('${wallpaperUrl}')`,backgroundSize: 'cover',@@ -1127,7 +1033,6 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functonMouseLeave={() => setIsVideoHovered(false)}onMouseDown={(e) => {if (!videoUrl || !onVideoTransformChange) return;- // Only start dragging if not clicking on rotation handleif ((e.target as HTMLElement).closest('[data-rotation-handle]')) return;e.preventDefault();@@ -1143,7 +1048,6 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functonMouseMove={(e) => { if (videoUrl) setVideoHoverCorner(getNearestCorner(e, videoTransform.rotation)); }}><div className="relative">- {/* Rotation handle */}{isVideoHovered && videoUrl && onVideoTransformChange && (<divdata-rotation-handle style={getCornerStyle(videoHoverCorner, -14)}@@ -1178,14 +1082,13 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct>{videoUrl ? (<div className="relative flex items-center justify-center overflow-hidden max-w-full max-h-full rounded-[inherit]"- > {/* Video element - src managed imperatively via videoRef, NOT as React prop */}+ ><videoref={videoRef}preload="auto"playsInlineclassName="max-w-full max-h-full object-contain"style={{- // Aplicar crop usando object-view-box (CSS nativo)...(cropArea && (cropArea.width < 100 || cropArea.height < 100 || cropArea.x > 0 || cropArea.y > 0) ? {objectViewBox: `inset(${cropArea.y}% ${100 - cropArea.x - cropArea.width}% ${100 - cropArea.y - cropArea.height}% ${cropArea.x}%)`,} : {}),@@ -1216,10 +1119,8 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct</div></div></div>- {/* End zoom transform div */}</div></div>- {/* End perspective wrapper div */}{/* Capa 3: Canvas elements ABOVE video (zIndex >= VIDEO_Z_INDEX) */}<CanvasElementsLayercanvasContainerRef={canvasContainerRef}@@ -1244,12 +1145,16 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functstyle={{ zIndex: 4 }}><div+ tabIndex={0} // Permite que el elemento reciba foco (se seleccione)onClick={() => {if (onCameraClick) {onCameraClick();}}}onPointerDown={(e) => {+ // Al hacer click o empezar a arrastrar, le damos el foco instantáneo+ e.currentTarget.focus();+if (!onCameraConfigChange || !cameraConfig) return;if (e.button !== 0) return;const container = previewContainerRef.current;@@ -1268,7 +1173,8 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct}}onPointerMove={(e) => {const drag = cameraDragRef.current;- if (!drag || drag.pointerId !== e.pointerId || !onCameraConfigChange) return;+ if (!drag || drag.pointerId !== e.pointerId || !onCameraConfigChange)+ return;const dx = (e.clientX - drag.startX) / drag.rect.width;const dy = (e.clientY - drag.startY) / drag.rect.height;const nextX = Math.min(1, Math.max(0, drag.initialX + dx));@@ -1292,15 +1198,33 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functcameraDragRef.current = null;setIsDraggingCamera(false);}}- className={`absolute pointer-events-auto select-none group ${onCameraConfigChange ? (isDraggingCamera ? "cursor-grabbing" : "cursor-grab") : ""+ className={`absolute pointer-events-auto select-none group focus:outline-none ${onCameraConfigChange+ ? isDraggingCamera+ ? "cursor-grabbing"+ : "cursor-grab"+ : ""}`}style={{width: `${cameraConfig.size * 100}cqmin`,aspectRatio: "1 / 1",- left: `clamp(0px, calc(${cameraConfig.position.x * 100}% - ${cameraConfig.size * 50}cqmin), calc(100% - ${cameraConfig.size * 100}cqmin))`,- top: `clamp(0px, calc(${cameraConfig.position.y * 100}% - ${cameraConfig.size * 50}cqmin), calc(100% - ${cameraConfig.size * 100}cqmin))`,- transition: isDraggingCamera ? "none" : "left 120ms ease, top 120ms ease",+ left: `clamp(0px, calc(${cameraConfig.position.x * 100}% - ${cameraConfig.size * 50+ }cqmin), calc(100% - ${cameraConfig.size * 100}cqmin))`,+ top: `clamp(0px, calc(${cameraConfig.position.y * 100}% - ${cameraConfig.size * 50+ }cqmin), calc(100% - ${cameraConfig.size * 100}cqmin))`,+ transition: isDraggingCamera+ ? "none"+ : "left 120ms ease, top 120ms ease",touchAction: "none",+ borderRadius:+ cameraConfig.shape === "circle"+ ? "50%"+ : cameraConfig.shape === "squircle"+ ? `${Math.round(+ 20 * (0.5 + (cameraConfig.size * 100 - 20) / 40)+ )}px`+ : `${Math.round(+ 6 * (0.5 + (cameraConfig.size * 100 - 20) / 40)+ )}px`,}}><video@@ -1308,62 +1232,16 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functmutedplaysInlinepreload="auto"- className={`size-full object-cover shadow-[0_8px_30px_rgba(0,0,0,0.45)] ring-1 ring-white/15 ${cameraConfig.shape === "squircle" ? "squircle-element-camara" : ""+ className={`size-full object-cover shadow-[0_8px_30px_rgba(0,0,0,0.45)] transition-all duration-150 ring-1 ring-white/10 group-hover:ring-1 group-hover:ring-white group-focus:ring-2 group-focus:ring-[#0066FF] group-focus:shadow-[0_0_0_4px_rgba(0,102,255,0.15)] ${cameraConfig.shape === "squircle" ? "squircle-element-camera" : ""}`}style={{- ...(cameraConfig.shape !== "squircle" && {- borderRadius:- cameraConfig.shape === "circle"- ? "50%"- : `${Math.round(6 * (0.5 + (cameraConfig.size - 20) / 40))}px`,- }),+ borderRadius: "inherit",transform: cameraConfig.mirror ? "scaleX(-1)" : undefined,}}/></div></div>)}- {/* Capa 5: Cursor overlay for preview */}- {/* {cursorPosition && cursorSvgDataUrl && cursorConfig.visible && cursorConfig.style !== "none" && (- <div- className="absolute inset-0 pointer-events-none"- style={{- zIndex: 4,- padding: `${padding * 0.5}%`,- }}- >- <div className="relative w-full h-full">- {cursorPosition.clicking && cursorConfig.clickEffect !== "none" && (- <div- className="absolute rounded-full animate-ping"- style={{- left: `${cursorPosition.x}%`,- top: `${cursorPosition.y}%`,- width: cursorConfig.size * 2,- height: cursorConfig.size * 2,- transform: 'translate(-50%, -50%)',- backgroundColor: cursorConfig.clickEffectColor,- opacity: cursorConfig.clickEffect === "ripple" ? 0.3 : 0.5,- }}- />- )}- <img- src={cursorSvgDataUrl}- alt="cursor"- className="absolute pointer-events-none"- style={{- left: `${cursorPosition.x}%`,- top: `${cursorPosition.y}%`,- width: cursorConfig.size,- height: cursorConfig.size,- // Cursor hotspot at top-left for arrow cursors- transform: 'translate(0, 0)',- transition: cursorConfig.smoothing > 50 ? `all ${cursorConfig.smoothing}ms ease-out` : 'none',- }}- />- </div>- </div>- )} */}</div></div></div>diff --git a/app/components/ui/editor/ZoomFragmentEditor.tsx b/app/components/ui/editor/ZoomFragmentEditor.tsxindex 64665b6..318ea5c 100644--- a/app/components/ui/editor/ZoomFragmentEditor.tsx+++ b/app/components/ui/editor/ZoomFragmentEditor.tsx@@ -169,7 +169,7 @@ export function ZoomFragmentEditor({</div><divref={focusPreviewRef}- className="relative w-full squircle-element overflow-hidden bg-[#0a0a0e] border border-white/10"+ className="relative w-full squircle-element overflow-hidden bg-[#0a0a0e] border border-white/10 select-none"style={{ aspectRatio: videoDimensions ? `${videoDimensions.width}/${videoDimensions.height}` : "16/9" }}onClick={handlePreviewClick}>@@ -177,18 +177,18 @@ export function ZoomFragmentEditor({<imgsrc={dynamicThumbnail}alt="Video preview"- className="absolute inset-0 w-full h-full object-cover opacity-60"+ className="absolute inset-0 w-full h-full object-cover opacity-60 pointer-events-none"/>) : videoUrl ? (<videosrc={videoUrl}- className="absolute inset-0 w-full h-full object-cover opacity-60"+ className="absolute inset-0 w-full h-full object-cover opacity-60 pointer-events-none"muted/>) : null}<div- className="absolute border border-dashed border-blue-500/50 bg-linear-to-b from-blue-500/20 to-transparent squircle-element pointer-events-none transition-all duration-200"+ className="absolute border border-dashed border-blue-500/50 bg-linear-to-b from-blue-500/20 to-transparent squircle-element pointer-events-none transition-opacity duration-200"style={{width: `${100 / zoomLevelToFactor(fragment.zoomLevel)}%`,height: `${100 / zoomLevelToFactor(fragment.zoomLevel)}%`,@@ -196,6 +196,7 @@ export function ZoomFragmentEditor({top: `${fragment.focusY}%`,transform: 'translate(-50%, -50%)',opacity: movementEnabled && editingPoint === 'end' ? 0.4 : 1,+ willChange: "left, top"}}/>@@ -211,7 +212,7 @@ export function ZoomFragmentEditor({const y2 = fragment.focusY + dy * ratio;return (- <svg className="absolute inset-0 w-full h-full pointer-events-none" style={{ zIndex: 5 }}>+ <svg className="absolute inset-0 w-full h-full pointer-events-none" style={{ zIndex: 5, willChange: "contents" }}><defs><marker id="arrowhead" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto"><polygon points="0 0, 10 3.5, 0 7" fill="rgba(16, 185, 129, 0.7)" />@@ -233,7 +234,7 @@ export function ZoomFragmentEditor({{movementEnabled && (<div- className="absolute border border-dashed border-emerald-500/50 bg-linear-to-b from-emerald-500/20 to-transparent squircle-element pointer-events-none transition-all duration-200"+ className="absolute border border-dashed border-emerald-500/50 bg-linear-to-b from-emerald-500/20 to-transparent squircle-element pointer-events-none transition-opacity duration-200"style={{width: `${100 / zoomLevelToFactor(fragment.zoomLevel)}%`,height: `${100 / zoomLevelToFactor(fragment.zoomLevel)}%`,@@ -241,18 +242,19 @@ export function ZoomFragmentEditor({top: `${movementEndY}%`,transform: 'translate(-50%, -50%)',opacity: editingPoint === 'start' ? 0.4 : 1,+ willChange: "left, top"}}/>)}<divdata-drag-handle- className={`absolute z-10 cursor-grab active:cursor-grabbing transition-all ${movementEnabled && editingPoint === 'end' ? 'opacity-60 scale-90' : ''- }`}+ className={`absolute z-10 cursor-grab active:cursor-grabbing touch-none transition-[opacity,transform] duration-150 ${movementEnabled && editingPoint === 'end' ? 'opacity-60 scale-90' : ''}`}style={{left: `${fragment.focusX}%`,top: `${fragment.focusY}%`,transform: "translate(-50%, -50%)",+ willChange: "left, top"}}onPointerDown={(e) => handlePointerDown(e, 'start')}>@@ -264,12 +266,12 @@ export function ZoomFragmentEditor({{movementEnabled && (<divdata-drag-handle- className={`absolute z-10 cursor-grab active:cursor-grabbing transition-all ${editingPoint === 'start' ? 'opacity-60 scale-90' : ''- }`}+ className={`absolute z-10 cursor-grab active:cursor-grabbing touch-none transition-[opacity,transform] duration-150 ${editingPoint === 'start' ? 'opacity-60 scale-90' : ''}`}style={{left: `${movementEndX}%`,top: `${movementEndY}%`,transform: "translate(-50%, -50%)",+ willChange: "left, top"}}onPointerDown={(e) => handlePointerDown(e, 'end')}>@@ -287,7 +289,6 @@ export function ZoomFragmentEditor({</div></div>- {/* Movement Toggle */}<div className="space-y-3 p-3 bg-white/3 border border-white/8 rounded-lg"><div className="flex items-center justify-between"><div className="flex items-center gap-2">@@ -331,30 +332,28 @@ export function ZoomFragmentEditor({const initialStartOffset = startOffset;const initialEndOffset = endOffset;+ // HACK: Forzamos un gap mínimo de tiempo equivalente a ~24px para evitar que los controles se solapen+ // Esto reemplaza el problemático "minWidth: '28px'" de CSS que rompía los límites.+ const minTimeGap = Math.max(0.1, (24 / (rect.width || 1)) * holdDuration);+const handleMove = (ev: MouseEvent) => {const deltaX = ev.clientX - initialX;const deltaPct = (deltaX / rect.width) * 100;const deltaTime = (deltaPct / 100) * holdDuration;if (type === 'start') {- const newStart = Math.max(0, Math.min(endOffset - 0.1, initialStartOffset + deltaTime));+ // Limitamos para no cruzar el endOffset ni salir de 0+ const newStart = Math.max(0, Math.min(initialEndOffset - minTimeGap, initialStartOffset + deltaTime));onUpdate({ movementStartOffset: Math.round(newStart * 10) / 10 });} else if (type === 'end') {- const newEnd = Math.max(startOffset + 0.1, Math.min(holdDuration, initialEndOffset + deltaTime));+ // Limitamos para no cruzar el startOffset ni salir de holdDuration+ const newEnd = Math.max(initialStartOffset + minTimeGap, Math.min(holdDuration, initialEndOffset + deltaTime));onUpdate({ movementEndOffset: Math.round(newEnd * 10) / 10 });} else if (type === 'range') {+ // Matemática simplificada y a prueba de errores para arrastrar el bloque enteroconst duration = initialEndOffset - initialStartOffset;- let newStart = initialStartOffset + deltaTime;- let newEnd = initialEndOffset + deltaTime;-- if (newStart < 0) {- newStart = 0;- newEnd = duration;- }- if (newEnd > holdDuration) {- newEnd = holdDuration;- newStart = holdDuration - duration;- }+ const newStart = Math.max(0, Math.min(holdDuration - duration, initialStartOffset + deltaTime));+ const newEnd = newStart + duration;onUpdate({movementStartOffset: Math.round(newStart * 10) / 10,@@ -402,7 +401,7 @@ export function ZoomFragmentEditor({<divclassName="absolute top-1.5 bottom-1.5 bg-emerald-500/20 border border-emerald-500/40 rounded-sm cursor-grab active:cursor-grabbing hover:bg-emerald-500/30 transition-all"style={{- left: `${moveStartPct}%`,+ left: `min(${moveStartPct}%, calc(100% - 28px))`,width: `${moveEndPct - moveStartPct}%`,minWidth: '28px'}}@@ -412,7 +411,7 @@ export function ZoomFragmentEditor({className="absolute -left-1.5 top-0 bottom-0 w-4 cursor-ew-resize group/left flex items-center justify-center z-20"onMouseDown={(e) => { e.stopPropagation(); handleTimelineDrag(e, 'start'); }}>- <div className="w-[2px] h-3 bg-emerald-400/50 group-hover/left:bg-emerald-300 rounded-full transition-colors" />+ <div className="w-0.5 h-3 bg-emerald-400/50 group-hover/left:bg-emerald-300 rounded-full transition-colors" /></div><div className="absolute inset-0 flex items-center justify-center pointer-events-none opacity-30">@@ -423,11 +422,11 @@ export function ZoomFragmentEditor({className="absolute -right-1.5 top-0 bottom-0 w-4 cursor-ew-resize group/right flex items-center justify-center z-20"onMouseDown={(e) => { e.stopPropagation(); handleTimelineDrag(e, 'end'); }}>- <div className="w-[2px] h-3 bg-emerald-400/50 group-hover/right:bg-emerald-300 rounded-full transition-colors" />+ <div className="w-0.5 h-3 bg-emerald-400/50 group-hover/right:bg-emerald-300 rounded-full transition-colors" /></div></div>- <div className="absolute inset-0 flex justify-between px-1 pointer-events-none opacity-10">+ <div className="absolute inset-0 flex justify-between px-1 pointer-events-none opacity-25">{[...Array(6)].map((_, i) => (<div key={i} className="w-px h-full bg-white" />))}@@ -445,11 +444,11 @@ export function ZoomFragmentEditor({<div className="flex items-center justify-between px-0.5"><div className="flex gap-4 text-[9px] font-mono text-white/30"><span className="flex items-center gap-1.5">- <span className="text-emerald-500/50">START</span>+ <span className="text-emerald-500/50">INICIO</span><span className="text-white/60">{startOffset.toFixed(1)}s</span></span><span className="flex items-center gap-1.5">- <span className="text-emerald-500/50">END</span>+ <span className="text-emerald-500/50">FIN</span><span className="text-white/60">{endOffset.toFixed(1)}s</span></span></div>diff --git a/app/globals.css b/app/globals.cssindex 28d795e..bef8b27 100644--- a/app/globals.css+++ b/app/globals.css@@ -165,7 +165,7 @@animation: text-shimmer 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;}- .squircle-element-camara {+ .squircle-element-camera {corner-shape: squircle;border-radius: 40px !important;}diff --git a/hooks/useVideoExport.ts b/hooks/useVideoExport.tsindex f8edaf5..3b44c55 100644--- a/hooks/useVideoExport.ts+++ b/hooks/useVideoExport.ts@@ -328,7 +328,7 @@ async function exportWithFFmpegWebM(// Actualizar progreso durante la codificación VP8ffmpeg.on("progress", ({ progress }) => {if (progress > 0) {- const encodingProgress = 70 + Math.round(progress * 20); // 70% → 90%+ const encodingProgress = 70 + Math.round(progress * 20);setProgress({status: "finalizing",progress: Math.min(encodingProgress, 90),