Skip to content

Commit

Permalink
Merge pull request #2281 from framer/fix/handoff-2
Browse files Browse the repository at this point in the history
Replace `requestAnimationFrame` timestamp with `performance.now()`
  • Loading branch information
mergetron[bot] authored Aug 7, 2023
2 parents 0fe2215 + 951169f commit f6123e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions dev/optimized-appear/resync-delay.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
const duration = 0.5
const x = motionValue(0)

x.onChange((latest) => {
if (latest < 50) {
x.on("change", (latest) => {
if (latest < 100) {
showError(
document.getElementById("box"),
`x transform should never be less than 50`
`x transform should never be less than 100`
)
}
})
Expand Down
8 changes: 6 additions & 2 deletions packages/framer-motion/src/frameloop/batcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export function createRenderBatcher(

const processStep = (stepId: StepId) => steps[stepId].process(state)

const processBatch = (timestamp: number) => {
const processBatch = () => {
const timestamp = performance.now()

runNextFrame = false

state.delta = useDefaultElapsed
Expand All @@ -54,7 +56,9 @@ export function createRenderBatcher(
runNextFrame = true
useDefaultElapsed = true

if (!state.isProcessing) scheduleNextBatch(processBatch)
if (!state.isProcessing) {
scheduleNextBatch(processBatch)
}
}

const schedule = stepsOrder.reduce((acc, key) => {
Expand Down

0 comments on commit f6123e5

Please sign in to comment.