diff options
| -rw-r--r-- | tools/timeline_editor/index.html | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/tools/timeline_editor/index.html b/tools/timeline_editor/index.html index d450522..fb813a5 100644 --- a/tools/timeline_editor/index.html +++ b/tools/timeline_editor/index.html @@ -730,9 +730,11 @@ e.preventDefault(); isDragging = true; - const rect = e.target.getBoundingClientRect(); - dragOffset.x = e.clientX - rect.left; - dragOffset.y = e.clientY - rect.top; + // Calculate offset from timeline origin (not from element edge) + const timelineRect = timeline.getBoundingClientRect(); + const currentLeft = parseFloat(e.target.style.left) || 0; + dragOffset.x = e.clientX - timelineRect.left - currentLeft; + dragOffset.y = e.clientY - e.target.getBoundingClientRect().top; selectedItem = { type, index: seqIndex, seqIndex, effectIndex }; renderTimeline(); @@ -759,9 +761,14 @@ if (selectedItem.type === 'sequence') { sequences[selectedItem.index].startTime = Math.round(newTime * 100) / 100; } else if (selectedItem.type === 'effect') { - const effect = sequences[selectedItem.seqIndex].effects[selectedItem.effectIndex]; + // Effects have times relative to their parent sequence + const seq = sequences[selectedItem.seqIndex]; + const effect = seq.effects[selectedItem.effectIndex]; const duration = effect.endTime - effect.startTime; - effect.startTime = Math.round(newTime * 100) / 100; + + // Convert absolute timeline position to relative time within sequence + const relativeTime = newTime - seq.startTime; + effect.startTime = Math.round(relativeTime * 100) / 100; effect.endTime = effect.startTime + duration; } @@ -849,7 +856,12 @@ effect.args = document.getElementById('propArgs').value; } + // Re-render timeline (recalculates sequence bounds) renderTimeline(); + + // Update properties panel to reflect any calculated changes + updateProperties(); + showMessage('Properties updated', 'success'); } |
