From 676cc1ef15653590eecf7f588fe02dd7d75863cc Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 23 Sep 2021 21:52:48 -0400
Subject: fixed trimming already trimmed clips.

---
 src/client/views/collections/CollectionStackedTimeline.tsx | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

(limited to 'src/client/views/collections/CollectionStackedTimeline.tsx')

diff --git a/src/client/views/collections/CollectionStackedTimeline.tsx b/src/client/views/collections/CollectionStackedTimeline.tsx
index 0985e5b2e..12d70c05d 100644
--- a/src/client/views/collections/CollectionStackedTimeline.tsx
+++ b/src/client/views/collections/CollectionStackedTimeline.tsx
@@ -63,6 +63,8 @@ export type CollectionStackedTimelineProps = {
     dictationKey: string;
     rawDuration: number;
     trimming: boolean;
+    clipStart: number;
+    clipEnd: number;
     trimStart: () => number;
     trimEnd: () => number;
     trimDuration: number;
@@ -332,7 +334,7 @@ export class CollectionStackedTimeline extends CollectionSubView<
                     this.props.setEndTrim(Math.max(
                         Math.min(
                             this.trimEnd + (e.movementX / rect.width) * this.duration,
-                            this.duration
+                            this.props.clipStart + this.duration
                         ),
                         this.trimStart + this.minLength
                     ));
@@ -582,7 +584,7 @@ export class CollectionStackedTimeline extends CollectionSubView<
                         start + (10 / timelineContentWidth) * this.duration
                     );
                     const left = this.props.trimming ?
-                        (start / this.duration) * timelineContentWidth
+                        ((start - this.props.clipStart) / this.duration) * timelineContentWidth
                         : Math.max((start - this.trimStart) / this.props.trimDuration * timelineContentWidth, 0);
                     const top = (d.level / maxLevel) * this.timelineContentHeight() + 15;
                     const timespan = end - start;
@@ -631,7 +633,7 @@ export class CollectionStackedTimeline extends CollectionSubView<
                     className="collectionStackedTimeline-current"
                     style={{
                         left: this.props.trimming
-                            ? `${(this.currentTime / this.duration) * 100}%`
+                            ? `${((this.currentTime - this.props.clipStart) / this.duration) * 100}%`
                             : `${(this.currentTime - this.trimStart) / (this.trimEnd - this.trimStart) * 100}%`,
                     }}
                 />
@@ -640,13 +642,13 @@ export class CollectionStackedTimeline extends CollectionSubView<
                     <>
                         <div
                             className="collectionStackedTimeline-trim-shade"
-                            style={{ width: `${(this.trimStart / this.duration) * 100}%` }}
+                            style={{ width: `${((this.trimStart - this.props.clipStart) / this.duration) * 100}%` }}
                         ></div>
 
                         <div
                             className="collectionStackedTimeline-trim-controls"
                             style={{
-                                left: `${(this.trimStart / this.duration) * 100}%`,
+                                left: `${((this.trimStart - this.props.clipStart) / this.duration) * 100}%`,
                                 width: `${((this.trimEnd - this.trimStart) / this.duration) * 100
                                     }%`,
                             }}
@@ -664,7 +666,7 @@ export class CollectionStackedTimeline extends CollectionSubView<
                         <div
                             className="collectionStackedTimeline-trim-shade"
                             style={{
-                                left: `${(this.trimEnd / this.duration) * 100}%`,
+                                left: `${((this.trimEnd - this.props.clipStart) / this.duration) * 100}%`,
                                 width: `${((this.duration - this.trimEnd) / this.duration) * 100
                                     }%`,
                             }}
-- 
cgit v1.2.3-70-g09d2

