Skip to content

Commit

Permalink
Add anchorPoint support for transitioning
Browse files Browse the repository at this point in the history
  • Loading branch information
cloxnu authored and JoeMatt committed Aug 29, 2022
1 parent c30a7a8 commit a76e9f6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/Animator/HeroCoreAnimationViewContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ internal class HeroCoreAnimationViewContext: HeroAnimatorViewContext {
state.cornerRadius != nil ||
state.opacity != nil ||
state.overlay != nil ||
state.anchorPoint != nil ||
state.backgroundColor != nil ||
state.borderColor != nil ||
state.borderWidth != nil ||
Expand Down Expand Up @@ -290,6 +291,9 @@ internal class HeroCoreAnimationViewContext: HeroAnimatorViewContext {
if let zPosition = targetState.zPosition {
rtn["zPosition"] = NSNumber(value: zPosition.native)
}
if let anchorPoint = targetState.anchorPoint {
rtn["anchorPoint"] = NSValue(cgPoint: anchorPoint)
}

if let borderWidth = targetState.borderWidth {
rtn["borderWidth"] = NSNumber(value: borderWidth.native)
Expand Down
1 change: 1 addition & 0 deletions Sources/HeroTargetState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public struct HeroTargetState {
public var cornerRadius: CGFloat?
public var backgroundColor: CGColor?
public var zPosition: CGFloat?
public var anchorPoint: CGPoint?

public var contentsRect: CGRect?
public var contentsScale: CGFloat?
Expand Down
3 changes: 3 additions & 0 deletions Sources/Preprocessors/SourcePreprocessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class SourcePreprocessor: BasePreprocessor {
if view.layer.contentsScale != targetView.layer.contentsScale {
state.contentsScale = targetView.layer.contentsScale
}
if view.layer.anchorPoint != targetView.layer.anchorPoint {
state.anchorPoint = targetView.layer.anchorPoint
}

context[view] = state
}
Expand Down

0 comments on commit a76e9f6

Please sign in to comment.