init commit
This commit is contained in:
78
remotion/node_modules/@remotion/studio/dist/helpers/get-timeline-sequence-layout.js
generated
vendored
Normal file
78
remotion/node_modules/@remotion/studio/dist/helpers/get-timeline-sequence-layout.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getTimelineSequenceLayout = exports.SEQUENCE_BORDER_WIDTH = void 0;
|
||||
const timeline_layout_1 = require("./timeline-layout");
|
||||
exports.SEQUENCE_BORDER_WIDTH = 1;
|
||||
const getWidthOfTrack = ({ durationInFrames, lastFrame, windowWidth, spatialDuration, nonNegativeMarginLeft, }) => {
|
||||
const fullWidth = windowWidth - timeline_layout_1.TIMELINE_PADDING * 2;
|
||||
const base = durationInFrames === Infinity || lastFrame === 0
|
||||
? fullWidth
|
||||
: (spatialDuration / lastFrame) * fullWidth;
|
||||
return base - exports.SEQUENCE_BORDER_WIDTH + nonNegativeMarginLeft;
|
||||
};
|
||||
const getTimelineSequenceLayout = ({ durationInFrames, startFrom, maxMediaDuration, startFromMedia, video, windowWidth, premountDisplay, postmountDisplay, }) => {
|
||||
var _a;
|
||||
const maxMediaSequenceDuration = (maxMediaDuration !== null && maxMediaDuration !== void 0 ? maxMediaDuration : Infinity) - startFromMedia;
|
||||
const lastFrame = ((_a = video.durationInFrames) !== null && _a !== void 0 ? _a : 1) - 1;
|
||||
let spatialDuration = Math.min(maxMediaSequenceDuration, durationInFrames - 1, lastFrame - startFrom);
|
||||
// Unclipped spatial duration: without the lastFrame - startFrom constraint
|
||||
let naturalSpatialDuration = Math.min(maxMediaSequenceDuration, durationInFrames - 1);
|
||||
const shouldAddHalfAFrameAtEnd = startFrom + durationInFrames < lastFrame;
|
||||
const shouldAddHalfAFrameAtStart = startFrom > 0;
|
||||
if (shouldAddHalfAFrameAtEnd) {
|
||||
spatialDuration += 0.5;
|
||||
naturalSpatialDuration += 0.5;
|
||||
}
|
||||
if (shouldAddHalfAFrameAtStart) {
|
||||
spatialDuration += 0.5;
|
||||
naturalSpatialDuration += 0.5;
|
||||
}
|
||||
const startFromWithOffset = shouldAddHalfAFrameAtStart
|
||||
? startFrom - 0.5
|
||||
: startFrom;
|
||||
const marginLeft = lastFrame === 0
|
||||
? 0
|
||||
: (startFromWithOffset / lastFrame) *
|
||||
(windowWidth - timeline_layout_1.TIMELINE_PADDING * 2);
|
||||
const nonNegativeMarginLeft = Math.min(marginLeft, 0);
|
||||
const width = getWidthOfTrack({
|
||||
durationInFrames,
|
||||
lastFrame,
|
||||
nonNegativeMarginLeft,
|
||||
spatialDuration,
|
||||
windowWidth,
|
||||
});
|
||||
const naturalWidth = getWidthOfTrack({
|
||||
durationInFrames,
|
||||
lastFrame,
|
||||
nonNegativeMarginLeft,
|
||||
spatialDuration: naturalSpatialDuration,
|
||||
windowWidth,
|
||||
});
|
||||
const premountWidth = premountDisplay
|
||||
? getWidthOfTrack({
|
||||
durationInFrames: premountDisplay,
|
||||
lastFrame,
|
||||
nonNegativeMarginLeft,
|
||||
spatialDuration: premountDisplay,
|
||||
windowWidth,
|
||||
})
|
||||
: null;
|
||||
const postmountWidth = postmountDisplay
|
||||
? getWidthOfTrack({
|
||||
durationInFrames: postmountDisplay,
|
||||
lastFrame,
|
||||
nonNegativeMarginLeft,
|
||||
spatialDuration: postmountDisplay,
|
||||
windowWidth,
|
||||
})
|
||||
: null;
|
||||
return {
|
||||
marginLeft: Math.max(marginLeft, 0) - (premountWidth !== null && premountWidth !== void 0 ? premountWidth : 0),
|
||||
width: width + (premountWidth !== null && premountWidth !== void 0 ? premountWidth : 0) + (postmountWidth !== null && postmountWidth !== void 0 ? postmountWidth : 0),
|
||||
naturalWidth: naturalWidth + (premountWidth !== null && premountWidth !== void 0 ? premountWidth : 0) + (postmountWidth !== null && postmountWidth !== void 0 ? postmountWidth : 0),
|
||||
premountWidth,
|
||||
postmountWidth,
|
||||
};
|
||||
};
|
||||
exports.getTimelineSequenceLayout = getTimelineSequenceLayout;
|
||||
Reference in New Issue
Block a user