Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Add support for animating border width and color. (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
jverkoey authored Dec 14, 2017
1 parent 23cd380 commit 55c23d5
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/MDMAnimatableKeyPaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ FOUNDATION_EXPORT MDMAnimatableKeyPath MDMKeyPathBackgroundColor NS_SWIFT_NAME(b
*/
FOUNDATION_EXPORT MDMAnimatableKeyPath MDMKeyPathBounds NS_SWIFT_NAME(bounds);

/**
Border width.
Equivalent UIView property: N/A
Equivalent CALayer property: borderWidth
Expected value type: CGFloat or NSNumber.
Additive animation supported: Yes.
*/
FOUNDATION_EXPORT MDMAnimatableKeyPath MDMKeyPathBorderWidth NS_SWIFT_NAME(borderWidth);

/**
Border color.
Equivalent UIView property: N/A
Equivalent CALayer property: borderColor
Expected value type: UIColor or CGColor.
Additive animation supported: No.
*/
FOUNDATION_EXPORT MDMAnimatableKeyPath MDMKeyPathBorderColor NS_SWIFT_NAME(borderColor);

/**
Corner radius.
Expand Down
2 changes: 2 additions & 0 deletions src/MDMAnimatableKeyPaths.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

MDMAnimatableKeyPath MDMKeyPathBackgroundColor = @"backgroundColor";
MDMAnimatableKeyPath MDMKeyPathBounds = @"bounds";
MDMAnimatableKeyPath MDMKeyPathBorderWidth = @"borderWidth";
MDMAnimatableKeyPath MDMKeyPathBorderColor = @"borderColor";
MDMAnimatableKeyPath MDMKeyPathCornerRadius = @"cornerRadius";
MDMAnimatableKeyPath MDMKeyPathHeight = @"bounds.size.height";
MDMAnimatableKeyPath MDMKeyPathOpacity = @"opacity";
Expand Down
2 changes: 2 additions & 0 deletions src/private/MDMBlockAnimations.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
animatableKeyPaths = [NSSet setWithArray:@[MDMKeyPathBackgroundColor,
MDMKeyPathBorderWidth,
MDMKeyPathBorderColor,
MDMKeyPathBounds,
MDMKeyPathCornerRadius,
MDMKeyPathHeight,
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/MotionAnimatorBehavioralTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class AnimatorBehavioralTests: XCTestCase {

private let properties: [AnimatableKeyPath: Any] = [
.backgroundColor: UIColor.blue,
.borderWidth: 5,
.borderColor: UIColor.red,
.bounds: CGRect(x: 0, y: 0, width: 123, height: 456),
.cornerRadius: 3,
.height: 100,
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/QuartzCoreBehavioralTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class QuartzCoreBehavioralTests: XCTestCase {

func testWhichPropertiesImplicitlyAnimateButNotAdditively() {
let properties: [AnimatableKeyPath: Any] = [
.borderWidth: 5,
.borderColor: UIColor.red,
.bounds: CGRect(x: 0, y: 0, width: 123, height: 456),
.cornerRadius: 3,
.height: 100,
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/UIKitBehavioralTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class UIKitBehavioralTests: XCTestCase {

func testSomePropertiesDoNotImplicitlyAnimate() {
let baselineProperties: [AnimatableKeyPath: Any] = [
.borderWidth: 5,
.borderColor: UIColor.red,
.cornerRadius: 3,
.shadowOffset: CGSize(width: 1, height: 1),
.shadowOpacity: 0.3,
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/UIKitEquivalencyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class UIKitEquivalencyTests: XCTestCase {

func testMostPropertiesImplicitlyAnimateAdditively() {
let baselineProperties: [AnimatableKeyPath: Any] = [
.borderWidth: 5,
.cornerRadius: 3,
.position: CGPoint(x: 50, y: 20),
.rotation: 42,
Expand Down Expand Up @@ -100,6 +101,7 @@ class UIKitEquivalencyTests: XCTestCase {
func testSomePropertiesImplicitlyAnimateButNotAdditively() {
let baselineProperties: [AnimatableKeyPath: Any] = [
.backgroundColor: UIColor.blue,
.borderColor: UIColor.red,
.opacity: 0.5,
]
for (keyPath, value) in baselineProperties {
Expand Down

0 comments on commit 55c23d5

Please sign in to comment.