Skip to content

Commit

Permalink
Merge pull request #80 from cashapp/nick/disable-coreanimation
Browse files Browse the repository at this point in the history
Disable implicit layer animations while rendering frames
  • Loading branch information
NickEntin authored Oct 4, 2024
2 parents a50ff45 + 6a832f3 commit d174d1a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/Stagehand/AnimationInstance/Renderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//

import Foundation
import QuartzCore

internal final class Renderer<ElementType: AnyObject>: AnyRenderer {

Expand Down Expand Up @@ -55,7 +56,13 @@ internal final class Renderer<ElementType: AnyObject>: AnyRenderer {
return
}

// Disable implicit layer animations while rendering the frame. Otherwise animations that include keyframes for animatable layer properties will not animate those properties in sync with the rest of the animation.
CATransaction.begin()
CATransaction.setDisableActions(true)

animation.apply(to: &element, at: relativeTimestamp, initialValues: initialValues)

CATransaction.commit()
}

func renderInitialFrame() {
Expand Down

0 comments on commit d174d1a

Please sign in to comment.