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

Commit 9be98e4

Browse files
author
Jeff Verkoeyen
committed
Merge branch 'release-candidate' into stable
2 parents fcdae0c + 90d121a commit 9be98e4

File tree

9 files changed

+46
-12
lines changed

9 files changed

+46
-12
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# 1.1.0
2+
3+
This minor change resolves some Xcode 9 warnings and introduces the ability to speed up or slow down animations.
4+
5+
## New features
6+
7+
- Added a new keypath constant, `MDMKeyPathScale`.
8+
- MDMAnimator animation timing can now be scaled using the new `timeScaleFactor` property.
9+
10+
## Source changes
11+
12+
* [If settlingDuration is unavailable, use the provided spring duration. (#5)](https://github.com/material-motion/motion-animator-objc/commit/4baa99681c0a73180bc0a25019dc575a5fee5ab1) (featherless)
13+
* [Resolve Xcode 9 warnings. (#7)](https://github.com/material-motion/motion-animator-objc/commit/6f84058ca729299261cae0865b8bbb1ccd163179) (featherless)
14+
* [Add a timeScaleFactor API to the animator. (#6)](https://github.com/material-motion/motion-animator-objc/commit/b2a0f96b617edea13517d33b20d8d95b10426bb7) (featherless)
15+
* [Add transform.scale keypath. (#3)](https://github.com/material-motion/motion-animator-objc/commit/9bdf4f6e833283da452797a254a090da61607a2b) (featherless)
16+
117
# 1.0.1
218

319
This is a patch fix release to address build issues within Google's build environment.

MotionAnimator.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = "MotionAnimator"
33
s.summary = "A Motion Animator creates performant, interruptible animations from motion specs."
4-
s.version = "1.0.1"
4+
s.version = "1.1.0"
55
s.authors = "The Material Motion Authors"
66
s.license = "Apache 2.0"
77
s.homepage = "https://github.com/material-motion/motion-animator-objc"

Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PODS:
22
- CatalogByConvention (2.1.1)
3-
- MotionAnimator (1.0.1):
3+
- MotionAnimator (1.1.0):
44
- MotionInterchange
55
- MotionInterchange (1.0.1)
66

@@ -14,7 +14,7 @@ EXTERNAL SOURCES:
1414

1515
SPEC CHECKSUMS:
1616
CatalogByConvention: c3a5319de04250a7cd4649127fcfca5fe3322a43
17-
MotionAnimator: ddf0bc7f92605c81e4d9864167bf18aab84823c6
17+
MotionAnimator: 9d025cda7572737e5db5ca779eb28c767fe6cf45
1818
MotionInterchange: 7a7c355ba2ed5d36c5cf2ceb76cacd3d3680dbf5
1919

2020
PODFILE CHECKSUM: 634239e7b183e669593b273198da9227ed207777

src/MDMAnimatableKeyPaths.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ typedef NSString * const MDMAnimatableKeyPath __attribute__((swift_wrapper(enum)
2525
FOUNDATION_EXPORT MDMAnimatableKeyPath MDMKeyPathCornerRadius NS_SWIFT_NAME(cornerRadius);
2626
FOUNDATION_EXPORT MDMAnimatableKeyPath MDMKeyPathHeight NS_SWIFT_NAME(height);
2727
FOUNDATION_EXPORT MDMAnimatableKeyPath MDMKeyPathOpacity NS_SWIFT_NAME(opacity);
28+
FOUNDATION_EXPORT MDMAnimatableKeyPath MDMKeyPathScale NS_SWIFT_NAME(scale);
2829
FOUNDATION_EXPORT MDMAnimatableKeyPath MDMKeyPathWidth NS_SWIFT_NAME(width);
2930
FOUNDATION_EXPORT MDMAnimatableKeyPath MDMKeyPathX NS_SWIFT_NAME(x);
3031
FOUNDATION_EXPORT MDMAnimatableKeyPath MDMKeyPathY NS_SWIFT_NAME(y);

src/MDMAnimatableKeyPaths.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
MDMAnimatableKeyPath MDMKeyPathCornerRadius = @"cornerRadius";
2020
MDMAnimatableKeyPath MDMKeyPathHeight = @"bounds.size.height";
2121
MDMAnimatableKeyPath MDMKeyPathOpacity = @"opacity";
22+
MDMAnimatableKeyPath MDMKeyPathScale = @"transform.scale";
2223
MDMAnimatableKeyPath MDMKeyPathWidth = @"bounds.size.width";
2324
MDMAnimatableKeyPath MDMKeyPathX = @"position.x";
2425
MDMAnimatableKeyPath MDMKeyPathY = @"position.y";

src/MDMMotionAnimator.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
NS_SWIFT_NAME(MotionAnimator)
2828
@interface MDMMotionAnimator : NSObject
2929

30+
/**
31+
The scaling factor to apply to all time-related values.
32+
33+
For example, a timeScaleFactor of 2 will double the length of all animations.
34+
35+
1.0 by default.
36+
*/
37+
@property(nonatomic, assign) CGFloat timeScaleFactor;
38+
3039
/**
3140
If enabled, all animations will be added with their values reversed.
3241
@@ -83,7 +92,7 @@ NS_SWIFT_NAME(MotionAnimator)
8392
toLayer:(nonnull CALayer *)layer
8493
withValues:(nonnull NSArray *)values
8594
keyPath:(nonnull MDMAnimatableKeyPath)keyPath
86-
completion:(nullable void(^)())completion;
95+
completion:(nullable void(^)(void))completion;
8796

8897
/**
8998
Adds a block that will be invoked each time an animation is added to a layer.

src/MDMMotionAnimator.m

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static CGFloat simulatorAnimationDragCoefficient(void) {
3232

3333
static CAMediaTimingFunction* timingFunctionWithControlPoints(CGFloat controlPoints[4]);
3434
static NSArray* coerceUIKitValuesToCoreAnimationValues(NSArray *values);
35-
static CABasicAnimation *animationFromTiming(MDMMotionTiming timing);
35+
static CABasicAnimation *animationFromTiming(MDMMotionTiming timing, CGFloat timeScaleFactor);
3636
static void makeAnimationAdditive(CABasicAnimation *animation);
3737

3838
@implementation MDMMotionAnimator {
@@ -42,6 +42,7 @@ @implementation MDMMotionAnimator {
4242
- (instancetype)init {
4343
self = [super init];
4444
if (self) {
45+
_timeScaleFactor = 1;
4546
_additive = true;
4647
}
4748
return self;
@@ -58,7 +59,7 @@ - (void)animateWithTiming:(MDMMotionTiming)timing
5859
toLayer:(CALayer *)layer
5960
withValues:(NSArray *)values
6061
keyPath:(MDMAnimatableKeyPath)keyPath
61-
completion:(void(^)())completion {
62+
completion:(void(^)(void))completion {
6263
NSAssert([values count] == 2, @"The values array must contain exactly two values.");
6364

6465
if (_shouldReverseValues) {
@@ -74,7 +75,8 @@ - (void)animateWithTiming:(MDMMotionTiming)timing
7475
return;
7576
}
7677

77-
CABasicAnimation *animation = animationFromTiming(timing);
78+
CGFloat timeScaleFactor = simulatorAnimationDragCoefficient() * _timeScaleFactor;
79+
CABasicAnimation *animation = animationFromTiming(timing, timeScaleFactor);
7880

7981
if (animation) {
8082
animation.keyPath = keyPath;
@@ -100,7 +102,7 @@ - (void)animateWithTiming:(MDMMotionTiming)timing
100102

101103
if (timing.delay != 0) {
102104
animation.beginTime = ([layer convertTime:CACurrentMediaTime() fromLayer:nil]
103-
+ timing.delay * simulatorAnimationDragCoefficient());
105+
+ timing.delay * timeScaleFactor);
104106
animation.fillMode = kCAFillModeBackwards;
105107
}
106108

@@ -160,7 +162,7 @@ - (void)addCoreAnimationTracer:(void (^)(CALayer *, CAAnimation *))tracer {
160162
return values;
161163
}
162164

163-
static CABasicAnimation *animationFromTiming(MDMMotionTiming timing) {
165+
static CABasicAnimation *animationFromTiming(MDMMotionTiming timing, CGFloat timeScaleFactor) {
164166
CABasicAnimation *animation;
165167
switch (timing.curve.type) {
166168
case MDMMotionCurveTypeInstant:
@@ -171,7 +173,7 @@ - (void)addCoreAnimationTracer:(void (^)(CALayer *, CAAnimation *))tracer {
171173
case MDMMotionCurveTypeBezier:
172174
animation = [CABasicAnimation animation];
173175
animation.timingFunction = timingFunctionWithControlPoints(timing.curve.data);
174-
animation.duration = timing.duration * simulatorAnimationDragCoefficient();
176+
animation.duration = timing.duration * timeScaleFactor;
175177
break;
176178

177179
case MDMMotionCurveTypeSpring: {
@@ -182,7 +184,7 @@ - (void)addCoreAnimationTracer:(void (^)(CALayer *, CAAnimation *))tracer {
182184
if ([spring respondsToSelector:@selector(settlingDuration)]) {
183185
spring.duration = spring.settlingDuration;
184186
} else {
185-
spring.duration = 1;
187+
spring.duration = timing.duration;
186188
}
187189
animation = spring;
188190
break;

tests/unit/MotionAnimatorTests.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ - (void)testSpringAnimationFloatValue {
146146

147147
XCTAssertEqual(springAnimation.keyPath, keyPath);
148148

149-
XCTAssertEqual(springAnimation.duration, springAnimation.settlingDuration);
149+
if ([springAnimation respondsToSelector:@selector(settlingDuration)]) {
150+
XCTAssertEqual(springAnimation.duration, springAnimation.settlingDuration);
151+
} else {
152+
XCTAssertEqual(springAnimation.duration, timing.duration);
153+
}
150154
XCTAssertGreaterThan(springAnimation.beginTime, 0);
151155

152156
XCTAssertTrue(springAnimation.additive);

tests/unit/MotionAnimatorTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class MotionAnimatorTests: XCTestCase {
3030
animator.animate(with: timing, to: layer, withValues: [0, 1], keyPath: .cornerRadius)
3131
animator.animate(with: timing, to: layer, withValues: [0, 1], keyPath: .height)
3232
animator.animate(with: timing, to: layer, withValues: [0, 1], keyPath: .opacity)
33+
animator.animate(with: timing, to: layer, withValues: [0, 1], keyPath: .scale)
3334
animator.animate(with: timing, to: layer, withValues: [0, 1], keyPath: .width)
3435
animator.animate(with: timing, to: layer, withValues: [0, 1], keyPath: .x)
3536
animator.animate(with: timing, to: layer, withValues: [0, 1], keyPath: .y)

0 commit comments

Comments
 (0)