Skip to content

Commit

Permalink
Perf: Lazy render (#2736)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry authored Jul 18, 2024
1 parent 776d8ca commit 0ae9dd5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/framer-motion/src/render/VisualElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ export abstract class VisualElement<
}

render = () => {
this.isRenderScheduled = false
if (!this.current) return
this.triggerBuild()
this.renderInstance(
Expand All @@ -564,7 +565,13 @@ export abstract class VisualElement<
)
}

scheduleRender = () => frame.render(this.render, false, true)
private isRenderScheduled = false
scheduleRender = () => {
if (!this.isRenderScheduled) {
this.isRenderScheduled = true
frame.render(this.render, false, true)
}
}

/**
* Measure the current viewport box with or without transforms.
Expand Down

0 comments on commit 0ae9dd5

Please sign in to comment.