Skip to content

Commit

Permalink
Respect start frame with timeweb
Browse files Browse the repository at this point in the history
  • Loading branch information
workeffortwaste committed Nov 20, 2024
1 parent bb43860 commit 197e209
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,26 @@ const videoExport = async (options) => {

/* Progress the animation and take a screenshot */
let frameStep = 0
let wasteStep = 0

/* Timeweb won't properly jump to a startFrame for me so we're going to waste some frames before we start capturing to ensure compatibility with the custom startFrame. */
if (options.advance === 'timeweb') {
for (let x = 0; x < startFrame; x++) {
/* Time in ms to advance the frames */
const interval = 1000 / options.fps

/* Shift the ms along slightly to avoid errors with weird gsap code */
const ms = interval * wasteStep + 1
await page.evaluate(async (ms) => {
/* Prepare frame */
await window.timeweb.goTo(ms)
}, ms)

wasteStep++
}
}

/* The recording loop */
for (let x = startFrame; x < endFrame; x++) {
const frame = x / duration

Expand Down

0 comments on commit 197e209

Please sign in to comment.