Skip to content

Commit

Permalink
Making render check more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry committed Sep 20, 2024
1 parent b2a6148 commit f41e7e5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/framer-motion/src/render/VisualElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { findValueType } from "./dom/value-types/find"
import { complex } from "../value/types/complex"
import { getAnimatableNone } from "./dom/value-types/animatable-none"
import { createBox } from "../projection/geometry/models"
import { time } from "../frameloop/sync-time"

const propEventHandlers = [
"AnimationStart",
Expand Down Expand Up @@ -539,7 +540,6 @@ export abstract class VisualElement<
}

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

private isRenderScheduled = false
private renderScheduledAt = 0.0
scheduleRender = () => {
if (!this.isRenderScheduled) {
this.isRenderScheduled = true
const now = time.now()
if (this.renderScheduledAt < now) {
this.renderScheduledAt = now
frame.render(this.render, false, true)
}
}
Expand Down

0 comments on commit f41e7e5

Please sign in to comment.