diff --git a/src/BetweenSegments.jsx b/src/BetweenSegments.jsx index 1ccf90fa..e287f6f4 100644 --- a/src/BetweenSegments.jsx +++ b/src/BetweenSegments.jsx @@ -5,29 +5,39 @@ import { FaTrashAlt, FaSave } from 'react-icons/fa'; import { mySpring } from './animations'; import { saveColor } from './colors'; -const BetweenSegments = memo(({ start, end, duration, invertCutSegments }) => ( - -
- {invertCutSegments ? ( - - ) : ( - - )} -
- -)); +const BetweenSegments = memo(({ start, end, duration, invertCutSegments }) => { + const left = `${(start / duration) * 100}%`; + + return ( + +
+ {invertCutSegments ? ( + + ) : ( + + )} +
+ + ); +}); export default BetweenSegments; diff --git a/src/SegmentList.jsx b/src/SegmentList.jsx index 7b875b45..3692ab48 100644 --- a/src/SegmentList.jsx +++ b/src/SegmentList.jsx @@ -13,6 +13,7 @@ import useContextMenu from './hooks/useContextMenu'; import useUserSettings from './hooks/useUserSettings'; import { saveColor, controlsBackground, primaryTextColor } from './colors'; import { getSegColor } from './util/colors'; +import { mySpring } from './animations'; const buttonBaseStyle = { margin: '0 3px', borderRadius: 3, color: 'white', cursor: 'pointer', @@ -109,7 +110,7 @@ const Segment = memo(({ seg, index, currentSegIndex, formatTimecode, getFrameCou role="button" onClick={() => !invertCutSegments && onClick(index)} onDoubleClick={onDoubleClick} - layouy + layout style={{ originY: 0, margin: '5px 0', background: 'rgba(0,0,0,0.1)', border: `1px solid rgba(255,255,255,${isActive ? 1 : 0.3})`, padding: 5, borderRadius: 5, position: 'relative' }} initial={{ scaleY: 0 }} animate={{ scaleY: 1, opacity: !enabled && !invertCutSegments ? 0.5 : undefined }} @@ -258,6 +259,7 @@ const SegmentList = memo(({ initial={{ x: width }} animate={{ x: 0 }} exit={{ x: width }} + transition={mySpring} >
(
{t('Batch file list')} diff --git a/src/hooks/useSegments.js b/src/hooks/useSegments.js index d0309882..6893f7b3 100644 --- a/src/hooks/useSegments.js +++ b/src/hooks/useSegments.js @@ -156,7 +156,7 @@ export default ({ const inverseCutSegments = useMemo(() => { const inverted = !haveInvalidSegs && isDurationValid(duration) ? invertSegments(sortSegments(apparentCutSegments), true, true, duration) : undefined; - return (inverted || []).map((seg) => ({ ...seg, segId: `${seg.start}-${seg.end}` })); + return inverted || []; }, [apparentCutSegments, duration, haveInvalidSegs]); const invertAllSegments = useCallback(() => { diff --git a/src/segments.js b/src/segments.js index 0b4601b4..2f08a268 100644 --- a/src/segments.js +++ b/src/segments.js @@ -114,29 +114,37 @@ export function invertSegments(sortedCutSegments, includeFirstSegment, includeLa const ret = []; if (includeFirstSegment) { - if (sortedCutSegments[0].start > 0) { - ret.push({ + const firstSeg = sortedCutSegments[0]; + if (firstSeg.start > 0) { + const inverted = { start: 0, - end: sortedCutSegments[0].start, - }); + end: firstSeg.start, + }; + if (firstSeg.segId != null) inverted.segId = `start-${firstSeg.segId}`; + ret.push(inverted); } } sortedCutSegments.forEach((cutSegment, i) => { if (i === 0) return; - ret.push({ - start: sortedCutSegments[i - 1].end, + const previousSeg = sortedCutSegments[i - 1]; + const inverted = { + start: previousSeg.end, end: cutSegment.start, - }); + }; + if (previousSeg.segId != null && cutSegment.segId != null) inverted.segId = `${previousSeg.segId}-${cutSegment.segId}`; + ret.push(inverted); }); if (includeLastSegment) { - const last = sortedCutSegments[sortedCutSegments.length - 1]; - if (last.end < duration || duration == null) { - ret.push({ - start: last.end, + const lastSeg = sortedCutSegments[sortedCutSegments.length - 1]; + if (lastSeg.end < duration || duration == null) { + const inverted = { + start: lastSeg.end, end: duration, - }); + }; + if (lastSeg.segId != null) inverted.segId = `${lastSeg.segId}-end`; + ret.push(inverted); } }