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

Commit

Permalink
Merge branch 'release-candidate' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Verkoeyen committed Dec 19, 2017
2 parents f31562c + fa35516 commit ff39ecc
Show file tree
Hide file tree
Showing 22 changed files with 817 additions and 145 deletions.
4 changes: 2 additions & 2 deletions .jazzy.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module: MotionAnimator
module_version: 2.7.0
module_version: 2.8.0
sdk: iphonesimulator
umbrella_header: src/MotionAnimator.h
objc: true
github_url: https://github.com/material-motion/motion-animator-objc
github_file_prefix: https://github.com/material-motion/motion-animator-objc/tree/v2.7.0
github_file_prefix: https://github.com/material-motion/motion-animator-objc/tree/v2.8.0
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,68 @@
# 2.8.0

This minor release introduces support for animating more key paths and support for drop-in UIView animation API replacements.

## New features

The MotionAnimator can now implicitly animate the following CALayer properties: `anchorPoint`, `borderWidth`, `borderColor`, `shadowColor`, and `zPosition`.

There are now UIKit equivalency APIs that can be used as drop-in replacements for existing UIView animation code.

## Source changes

* [Add IS_BAZEL_BUILD around MotionInterchange import (#103)](https://github.com/material-motion/motion-animator-objc/commit/042eb8cb46c077121f817d5e8ebc7b51d4ec54b9) (Louis Romero)
* [Anchor point became animatable on iOS 11.](https://github.com/material-motion/motion-animator-objc/commit/a56cd92874440b975591e421eaad8d4ef28cb9d4) (Jeff Verkoeyen)
* [Add support for animating anchorPoint. (#97)](https://github.com/material-motion/motion-animator-objc/commit/646b6f6fd1ed3a10dae7ab4e98caa43cad65f2ff) (featherless)
* [Add support for animating shadow color. (#99)](https://github.com/material-motion/motion-animator-objc/commit/ca896623a4e5a42a458e6fd59c8f405b55e87e26) (featherless)
* [Add support for animating border width and color. (#98)](https://github.com/material-motion/motion-animator-objc/commit/55c23d5c4f8029cc45f6331a894ddf1960863ba7) (featherless)
* [Add support for animating z position. (#96)](https://github.com/material-motion/motion-animator-objc/commit/23cd380bf2414b2834da7f8d55548cd00166d6f8) (featherless)
* [Add support for additively animating bounds. (#93)](https://github.com/material-motion/motion-animator-objc/commit/32c78d4d93b6c82ff55693c54176b2826f718e5e) (featherless)
* [Improve the documentation for initial velocity. (#94)](https://github.com/material-motion/motion-animator-objc/commit/e260418023430e0541360ec46ed6d4d931dbf05c) (featherless)
* [Standardize our param docs formatting. (#95)](https://github.com/material-motion/motion-animator-objc/commit/024296aca338b106cf49b87fcc83b9feb216ee9d) (featherless)
* [Add back test properties that were accidentally removed in 69469aedb987e516ff1f43a123b3ee29dfef38ca.](https://github.com/material-motion/motion-animator-objc/commit/e41ccb4890b9ed3bad5ab52015f8224adb5bbba6) (Jeff Verkoeyen)
* [Add support for using a spring generator as a timing curve. (#91)](https://github.com/material-motion/motion-animator-objc/commit/46fd517e18b3a9555e46dcdd942601dd4ccd5149) (featherless)
* [Throw an assertion when an unrecognized timing curve is provided. (#92)](https://github.com/material-motion/motion-animator-objc/commit/1e76e2ba8fe9bc08d623a55623f5fd40579d0287) (featherless)
* [Add UIKit equivalent APIs for animating implicitly. (#90)](https://github.com/material-motion/motion-animator-objc/commit/69469aedb987e516ff1f43a123b3ee29dfef38ca) (featherless)

## API changes

Auto-generated by running:

apidiff origin/stable release-candidate objc src/MotionAnimator.h

#### Animatable key paths

*new* constant: `MDMKeyPathAnchorPoint`

*new* constant: `MDMKeyPathBorderWidth`

*new* constant: `MDMKeyPathBorderColor`

*new* constant: `MDMKeyPathShadowColor`

*new* constant: `MDMKeyPathZ`

#### MDMMotionAnimator(UIKitEquivalency)

*new* class method: `+animateWithDuration:delay:options:animations:completion:` in `MDMMotionAnimator(UIKitEquivalency)`

*new* class method: `+animateWithDuration:animations:completion:` in `MDMMotionAnimator(UIKitEquivalency)`

*new* class method: `+animateWithDuration:animations:` in `MDMMotionAnimator(UIKitEquivalency)`

*new* class method: `+animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:` in `MDMMotionAnimator(UIKitEquivalency)`

## Non-source changes

* [Animate the border as well to demonstrate that we can animate CALayer properties with the animator. (#101)](https://github.com/material-motion/motion-animator-objc/commit/e48cc459f281afde1ab2ae2c985b4fb64555c0f9) (featherless)
* [Add a UIKit-ish tap to bounce example as a contrast to the traits example. (#100)](https://github.com/material-motion/motion-animator-objc/commit/c04fd1a5ad5ba910cb609d5edf52f1fa2b88826f) (featherless)
* [Wording order.](https://github.com/material-motion/motion-animator-objc/commit/4bf33e213af26511e0aca40f42ebceb0a077076a) (Jeff Verkoeyen)
* [Min SDK support.](https://github.com/material-motion/motion-animator-objc/commit/0ca2e7c7e154da62fac508d6f8c21f1ff3b37c02) (Jeff Verkoeyen)
* [Fix the banner url.](https://github.com/material-motion/motion-animator-objc/commit/966ae6769288e4913219c7de156b846af5789d96) (Jeff Verkoeyen)
* [Add banner and drop most of the preamble docs in preparation for the new readme.](https://github.com/material-motion/motion-animator-objc/commit/cf183c788fba2fef2e144674d412da67d5adc438) (Jeff Verkoeyen)

---

# 2.7.0

This minor release introduces support for the new [v1.5.0](https://github.com/material-motion/motion-interchange-objc/releases/tag/v1.5.0) MotionInterchange format.
Expand Down
2 changes: 1 addition & 1 deletion MotionAnimator.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "MotionAnimator"
s.summary = "A Motion Animator creates performant, interruptible animations from motion specs."
s.version = "2.7.0"
s.version = "2.8.0"
s.authors = "The Material Motion Authors"
s.license = "Apache 2.0"
s.homepage = "https://github.com/material-motion/motion-animator-objc"
Expand Down
4 changes: 2 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- CatalogByConvention (2.2.0)
- MotionAnimator (2.7.0):
- MotionAnimator (2.8.0):
- MotionInterchange (~> 1.6)
- MotionInterchange (1.6.0)

Expand All @@ -14,7 +14,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
CatalogByConvention: 5df5831e48b8083b18570dcb804f20fd1c90694f
MotionAnimator: fe012f4b344f091f95a621b0d0a97c4e2ea1c525
MotionAnimator: 8af077dac084b7880a4d2ddae31a26171087bd87
MotionInterchange: ead0e3ae1f3a5fb539e289debbc7ae036160a10d

PODFILE CHECKSUM: 3537bf01c11174928ac008c20fec4738722e96f3
Expand Down
86 changes: 2 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,13 @@
# Motion Animator
![Motion Animator Banner](img/motion-animator-banner.gif)

> A Motion Animator creates performant, interruptible animations from motion specs.
> An animator for iOS 8+ that combines the best aspects of modern UIView and CALayer animation APIs.
[![Build Status](https://travis-ci.org/material-motion/motion-animator-objc.svg?branch=develop)](https://travis-ci.org/material-motion/motion-animator-objc)
[![codecov](https://codecov.io/gh/material-motion/motion-animator-objc/branch/develop/graph/badge.svg)](https://codecov.io/gh/material-motion/motion-animator-objc)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/MotionAnimator.svg)](https://cocoapods.org/pods/MotionAnimator)
[![Platform](https://img.shields.io/cocoapods/p/MotionAnimator.svg)](http://cocoadocs.org/docsets/MotionAnimator)

---

This library provides APIs that turn [Motion Interchange](https://github.com/material-motion/motion-interchange-objc)
**motion specifications** into animations.

---

#### What is a motion specification?

A **motion specification** defines the delay, duration, and acceleration of animations in a simple
data format that can live separate from your animation logic.

For example, let's say we wanted to describe the motion for this animation:

<img src="assets/chip.gif" />

We might create a specification like so:

```objc
struct CalendarChipTiming {
MDMMotionTiming chipWidth;
MDMMotionTiming chipHeight;
MDMMotionTiming chipY;

MDMMotionTiming chipContentOpacity;
MDMMotionTiming headerContentOpacity;

MDMMotionTiming navigationBarY;
};
typedef struct CalendarChipTiming CalendarChipTiming;

struct CalendarChipMotionSpec {
CalendarChipTiming expansion;
CalendarChipTiming collapse;
};
typedef struct CalendarChipMotionSpec CalendarChipMotionSpec;

FOUNDATION_EXTERN struct CalendarChipMotionSpec CalendarChipSpec;
```

With our implementation of the spec looking like so:

```objc
struct CalendarChipMotionSpec CalendarChipSpec = {
.expansion = {
.chipWidth = {
.delay = 0.000, .duration = 0.285, .curve = MDMEightyForty,
},
.chipHeight = {
.delay = 0.015, .duration = 0.360, .curve = MDMEightyForty,
},
...
},
.collapse = {
.chipWidth = {
.delay = 0.045, .duration = 0.330, .curve = MDMEightyForty,
},
.chipHeight = {
.delay = 0.000, .duration = 0.330, .curve = MDMEightyForty,
},
...
},
};
```

Our spec defines two different transition states: expansion and collapse. At runtime, we determine
which of these two specs we need and then use the timings to animate our views with an instance of
`MDMMotionAnimator`:

```objc
CalendarChipTiming timing = _expanded ? CalendarChipSpec.expansion : CalendarChipSpec.collapse;

MDMMotionAnimator *animator = [[MDMMotionAnimator alloc] init];
animator.shouldReverseValues = !_expanded;

[animator animateWithTiming:timing.chipHeight
toLayer:chipView.layer
withValues:@[ @(chipFrame.size.height), @(headerFrame.size.height) ]
keyPath:MDMKeyPathHeight];
...
```
A working implementation of this example can be seen in the included example app.

## Example apps/unit tests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import UIKit
import MotionAnimator

class TapToBounceExampleViewController: UIViewController {
// This demo shows how to use animation traits to define the timings for an animation.
class TapToBounceTraitsExampleViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -28,6 +29,10 @@ class TapToBounceExampleViewController: UIViewController {
circle.bounds = CGRect(x: 0, y: 0, width: 128, height: 128)
circle.center = view.center
circle.layer.cornerRadius = circle.bounds.width / 2
circle.layer.borderColor = UIColor(red: (CGFloat)(0x88) / 255.0,
green: (CGFloat)(0xEF) / 255.0,
blue: (CGFloat)(0xAA) / 255.0,
alpha: 1).cgColor
circle.backgroundColor = UIColor(red: (CGFloat)(0xEF) / 255.0,
green: (CGFloat)(0x88) / 255.0,
blue: (CGFloat)(0xAA) / 255.0,
Expand All @@ -50,13 +55,18 @@ class TapToBounceExampleViewController: UIViewController {
let animator = MotionAnimator()
animator.animate(with: traits) {
sender.transform = CGAffineTransform(scaleX: 1.5, y: 1.5)

// This would normally not be animatable with the UIView animation APIs, but it is animatable
// with the motion animator.
sender.layer.borderWidth = 10
}
}

func didUnfocus(_ sender: UIButton) {
let animator = MotionAnimator()
animator.animate(with: traits) {
sender.transform = .identity
sender.layer.borderWidth = 0
}
}
}
Expand Down
76 changes: 76 additions & 0 deletions examples/TapToBounceUIKitExample.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
Copyright 2017-present The Material Motion Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import UIKit
import MotionAnimator

// This demo shows how to the MotionAnimator UIKit-ish APIs for animating properties and is provided
// as a contrast to the TapToBounceTraits example.
class TapToBounceUIKitExampleViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

view.backgroundColor = .white

let circle = UIButton()
circle.bounds = CGRect(x: 0, y: 0, width: 128, height: 128)
circle.center = view.center
circle.layer.cornerRadius = circle.bounds.width / 2
circle.layer.borderColor = UIColor(red: (CGFloat)(0x88) / 255.0,
green: (CGFloat)(0xEF) / 255.0,
blue: (CGFloat)(0xAA) / 255.0,
alpha: 1).cgColor
circle.backgroundColor = UIColor(red: (CGFloat)(0xEF) / 255.0,
green: (CGFloat)(0x88) / 255.0,
blue: (CGFloat)(0xAA) / 255.0,
alpha: 1)
view.addSubview(circle)

circle.addTarget(self, action: #selector(didFocus),
for: [.touchDown, .touchDragEnter])
circle.addTarget(self, action: #selector(didUnfocus),
for: [.touchUpInside, .touchUpOutside, .touchDragExit])
}

func didFocus(_ sender: UIButton) {
MotionAnimator.animate(withDuration: 0.8,
delay: 0,
usingSpringWithDamping: 0.5,
initialSpringVelocity: 0,
options: [],
animations: {
sender.transform = CGAffineTransform(scaleX: 1.5, y: 1.5)

// This would normally not be animatable with the UIView animation APIs, but it is animatable
// with the motion animator.
sender.layer.borderWidth = 10
}, completion: nil)
}

func didUnfocus(_ sender: UIButton) {
MotionAnimator.animate(withDuration: 0.8,
delay: 0,
usingSpringWithDamping: 0.5,
initialSpringVelocity: 0,
options: [],
animations: {
sender.transform = .identity
sender.layer.borderWidth = 0
}, completion: nil)
}
}

Loading

0 comments on commit ff39ecc

Please sign in to comment.