Skip to content

Commit 83210a8

Browse files
authored
Fix(Regions): region can't be dragged to position 0 and duration. (#4199)
* Fix(Regions): region can't be dragged to position 0 and duration. * chore:(Regions): move the length calculation
1 parent aa86c9b commit 83210a8

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/plugins/regions.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ class SingleRegion extends EventEmitter<RegionEvents> implements Region {
295295
const deltaSeconds = (dx / width) * this.totalDuration
296296
let newStart = !side || side === 'start' ? this.start + deltaSeconds : this.start
297297
let newEnd = !side || side === 'end' ? this.end + deltaSeconds : this.end
298-
const length = newEnd - newStart
299298

300299
if (this.updatingSide && this.updatingSide !== side && startTime !== undefined) {
301300
if (this.updatingSide === 'start') {
@@ -305,15 +304,13 @@ class SingleRegion extends EventEmitter<RegionEvents> implements Region {
305304
}
306305
}
307306

307+
newStart = Math.max(0, newStart)
308+
newEnd = Math.min(this.totalDuration, newEnd)
309+
const length = newEnd - newStart
310+
308311
this.updatingSide = side
309312

310-
if (
311-
newStart >= 0 &&
312-
newEnd <= this.totalDuration &&
313-
newStart <= newEnd &&
314-
length >= this.minLength &&
315-
length <= this.maxLength
316-
) {
313+
if (newStart <= newEnd && length >= this.minLength && length <= this.maxLength) {
317314
this.start = newStart
318315
this.end = newEnd
319316

0 commit comments

Comments
 (0)