v1.3.0
Highlights:
- First contribution from Eric Tang adding support for
DispatchTimeInterval
initialization of time-based interactions and operators. - New visualization tools for streams.
- All gestural interactions can now be reactively enabled and disabled.
- Transitions APIs are evolving as we begin work on components. View the roadmap for more details.
Behavioral changes
• defaultTransitionSpringTension
and defaultTransitionSpringFriction
's values have been swapped to match the actual default values for tension and friction. These values were previously incorrectly reversed.
• Operators that do not support Core Animation will no longer throw runtime assertions when receiving Core Animation events. We have an open issue to explore nicer handling of operators and properties that do not support Core Animation.
New features
Runtime
• MotionRuntime now allows you to retrieve interactions associated with a given target with the new interactions(for:filter:)
API.
Example usage:
let draggables = runtime.interactions(for: view) { $0 as? Draggable }
Interactions
• PathTween
, Tween
, TransitionTween
each have a new convenience initializer that accepts the DispatchTimeInterval
enum, making it possible to specify explicit time units. Contributed by Eric Tang.
Example usage:
let tween = Tween<CGFloat>(duration: .milliseconds(300), values: [1, 0])
• Draggable
, Rotatable
, Scalable
, and DirectlyManipulable
now all conform to the Togglable
type, meaning they can be reactively enabled and disabled.
Example usage:
draggable.enabled.value = false // Disables the interaction
Operators
• delay(by:)
now accepts a DispatchTimeInterval
enum, making it possible to specify explicit time units. Contributed by Eric Tang.
let delayedStream = stream.delay(by: .seconds(1))
• toString()
transforms any stream into a string representation. This is part of our Reactive Controls milestone.
let stringStream = stream.toStream()
• visualize(in:)
allows you to display a stream's values and changes in your app with a new visualization overlay that appears atop your runtime's container view.
Example usage:
runtime.add(tossable, to: view) { $0.visualize(in: runtime.visualizationView) }
API changes
Runtime
• MotionRuntime's add
method now requires that targets conform to AnyObject. This will not affect any of the existing Interactions included with Material Motion. What this change means is that you can no longer build interactions that target non-object types.
Transitions
• TransitionController is now a pure Swift class type. This means TransitionController is no longer visible to Objective-C code. See #108 for our discussion on Objective-C support.
• TransitionController
now exposes a transitioningDelegate
property. TransitionController
no longer conforms to UIViewControllerTransitioningDelegate
.
// Before
viewController.transitioningDelegate = viewController.transitionController
// After
viewController.transitioningDelegate = viewController.transitionController.transitioningDelegate
Source changes
- Added convenience constructor that takes DispatchTimeInterval for duration (#107) (Eric Tang)
- Make ViewControllerDismisser a pure Swift class. (Jeff Verkoeyen)
- Make TransitionController a pure Swift class. (Jeff Verkoeyen)
- Add runtime.interactions(for:) API for fetching interactions associated with a given target. (Jeff Verkoeyen)
- Properly compare visualize's label text against the prefixed value string. (Jeff Verkoeyen)
- Add visualize operator and remove runtime.visualize. (Jeff Verkoeyen)
- Make all gestural interactions conform to Togglable. (Jeff Verkoeyen)
- Use a reasonable fallback when adding visualization views to the runtime container view. (Jeff Verkoeyen)
- Add runtime.visualize for visualizing values emitted by streams. (Jeff Verkoeyen)
- Remove runtime assertion when core animation events are sent to operators that don't support them. (Jeff Verkoeyen)
- Add toString operator. (Jeff Verkoeyen)
- Swap the default transition tension/friction values to match the proper variable names. (Jeff Verkoeyen)
API changes
Auto-generated by running:
apidiff origin/stable release-candidate swift MaterialMotion.xcworkspace MaterialMotion
MotionRuntime
new method: interactions(for:filter:)
in MotionRuntime
modified method: add(_:to:constraints:)
in MotionRuntime
: targets must now conform to AnyObject.
new var: visualizationView
in MotionRuntime
New operators
new method: delay(by:)
in MotionObservableConvertible
new method: toString()
in MotionObservableConvertible
new method: visualize(_:in:)
in MotionObservableConvertible
Interactions
DirectlyManipulable
modified class: DirectlyManipulable
Type of change: | Declaration |
---|---|
From: | public final class DirectlyManipulable : NSObject, Interaction, Stateful |
To: | public final class DirectlyManipulable : NSObject, Interaction, Togglable, Stateful |
Draggable
modified class: Draggable
Type of change: | Declaration |
---|---|
From: | public final class Draggable : Gesturable<UIPanGestureRecognizer>, Interaction, Stateful |
To: | public final class Draggable : Gesturable<UIPanGestureRecognizer>, Interaction, Togglable, Stateful |
Gesturable
new var: enabled
in Gesturable
PathTween
new method: init(duration:path:system:timeline:)
in PathTween
Rotatable
modified class: Rotatable
Type of change: | Declaration |
---|---|
From: | public final class Rotatable : Gesturable<UIRotationGestureRecognizer>, Interaction, Stateful |
To: | public final class Rotatable : Gesturable<UIRotationGestureRecognizer>, Interaction, Togglable, Stateful |
Scalable
modified class: Scalable
Type of change: | Declaration |
---|---|
From: | public final class Scalable : Gesturable<UIPinchGestureRecognizer>, Interaction, Stateful |
To: | public final class Scalable : Gesturable<UIPinchGestureRecognizer>, Interaction, Togglable, Stateful |
Tween
new method: init(duration:values:system:timeline:)
in Tween
TransitionTween
new method: init(duration:forwardValues:direction:forwardKeyPositions:system:timeline:)
in TransitionTween
Transitions
TransitionController
modified class: TransitionController
Type of change: | Declaration |
---|---|
From: | public final class TransitionController : NSObject |
To: | public final class TransitionController |
new var: transitioningDelegate
in TransitionController
ViewControllerDismisser
new var: gestureRecognizers
in ViewControllerDismisser