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

Commit b0a5f37

Browse files
authored
Add bounds to the list of supported key paths. (#68)
1 parent f05e787 commit b0a5f37

6 files changed

+18
-1
lines changed

src/MDMAnimatableKeyPaths.h

+10
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ typedef NSString * const MDMAnimatableKeyPath CF_TYPED_ENUM;
5252
*/
5353
FOUNDATION_EXPORT MDMAnimatableKeyPath MDMKeyPathBackgroundColor NS_SWIFT_NAME(backgroundColor);
5454

55+
/**
56+
Bounds.
57+
58+
Equivalent UIView property: bounds
59+
Equivalent CALayer property: bounds
60+
Expected value type: CGRect or NSValue (containing a CGRect).
61+
Additive animation supported: Yes.
62+
*/
63+
FOUNDATION_EXPORT MDMAnimatableKeyPath MDMKeyPathBounds NS_SWIFT_NAME(bounds);
64+
5565
/**
5666
Corner radius.
5767

src/MDMAnimatableKeyPaths.m

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#import "MDMAnimatableKeyPaths.h"
1818

1919
MDMAnimatableKeyPath MDMKeyPathBackgroundColor = @"backgroundColor";
20+
MDMAnimatableKeyPath MDMKeyPathBounds = @"bounds";
2021
MDMAnimatableKeyPath MDMKeyPathCornerRadius = @"cornerRadius";
2122
MDMAnimatableKeyPath MDMKeyPathHeight = @"bounds.size.height";
2223
MDMAnimatableKeyPath MDMKeyPathOpacity = @"opacity";

tests/unit/ImplicitAnimationTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class ImplicitAnimationTests: XCTestCase {
162162
do {
163163
let animation = addedAnimations
164164
.flatMap { $0 as? CABasicAnimation }
165-
.first(where: { $0.keyPath == "bounds"})!
165+
.first(where: { $0.keyPath == AnimatableKeyPath.bounds.rawValue})!
166166
XCTAssertFalse(animation.isAdditive)
167167
XCTAssertEqual(animation.fromValue as! CGRect, .init(x: 0, y: 0, width: 0, height: 0))
168168
XCTAssertEqual(animation.toValue as! CGRect, .init(x: 0, y: 0, width: 100, height: 100))

tests/unit/MotionAnimatorTests.swift

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class MotionAnimatorTests: XCTestCase {
3434

3535
animator.animate(with: timing, to: layer,
3636
withValues: [UIColor.blue, UIColor.red], keyPath: .backgroundColor)
37+
animator.animate(with: timing, to: layer,
38+
withValues: [CGRect.zero, CGRect(x: 0, y: 0, width: 100, height: 50)],
39+
keyPath: .bounds)
3740
animator.animate(with: timing, to: layer, withValues: [0, 1], keyPath: .cornerRadius)
3841
animator.animate(with: timing, to: layer, withValues: [0, 1], keyPath: .height)
3942
animator.animate(with: timing, to: layer, withValues: [0, 1], keyPath: .opacity)

tests/unit/QuartzCoreBehavioralTests.swift

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class QuartzCoreBehavioralTests: XCTestCase {
7474

7575
func testWhichPropertiesImplicitlyAnimateButNotAdditively() {
7676
let properties: [AnimatableKeyPath: Any] = [
77+
.bounds: CGRect(x: 0, y: 0, width: 123, height: 456),
7778
.cornerRadius: 3,
7879
.height: 100,
7980
.opacity: 0.5,

tests/unit/UIKitBehavioralTests.swift

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class UIKitBehavioralTests: XCTestCase {
7171

7272
func testSomePropertiesImplicitlyAnimateAdditively() {
7373
let properties: [AnimatableKeyPath: Any] = [
74+
.bounds: CGRect(x: 0, y: 0, width: 123, height: 456),
7475
.cornerRadius: 3,
7576
.height: 100,
7677
.position: CGPoint(x: 50, y: 20),
@@ -150,6 +151,7 @@ class UIKitBehavioralTests: XCTestCase {
150151
func testNoPropertiesImplicitlyAnimateOutsideOfAnAnimationBlock() {
151152
let properties: [AnimatableKeyPath: Any] = [
152153
.backgroundColor: UIColor.blue,
154+
.bounds: CGRect(x: 0, y: 0, width: 123, height: 456),
153155
.cornerRadius: 3,
154156
.height: 100,
155157
.opacity: 0.5,

0 commit comments

Comments
 (0)