TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | Apache 2 |
ReleasedLast Release | Feb 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Jeff Verkoeyen.
Depends on: | |
pop | ~> 1.0 |
MaterialMotionTransitions | ~> 1.0 |
MaterialMotionPop | ~> 2.0 |
TransitionSpring
makes it easy to describe bi-directional spring-based transitions.
Consider the following example of a simple “slide in” transition director:
class SlideInTransitionDirector: NSObject, TransitionDirector {
let transition: Transition
required init(transition: Transition) {
self.transition = transition
}
func setUp() {
let midY = Double(transition.foreViewController.view.layer.position.y)
let height = Double(transition.foreViewController.view.bounds.height)
let slide = TransitionSpring("position.y",
transition: transition,
back: NSNumber(value: midY + height),
fore: NSNumber(value: midY))
transition.runtime.addPlan(slide, to: transition.foreViewController.view.layer)
}
}
In this director we’ve defined a single TransitionSpring that handles both the forward and backward transition. Going forward, a SpringTo
with destination midY is emitted. Going backward, a SpringTo
with destination midY + height is emitted.
Import the framework:
@import MaterialMotionPopTransitions;
You will now have access to all of the APIs.
Check out a local copy of the repo to access the Catalog application by running the following commands:
git clone https://github.com/material-motion/pop-transitions-swift.git
cd pop-transitions-swift
pod install
open MaterialMotionPopTransitions.xcworkspace
Code snippets:
In Objective-C:
MDMTransitionSpring *spring = [[MDMTransitionSpring alloc] initWithProperty:"<#key path#>"
transition:transition
back:<#back value#>
fore:<#fore value#>];
[scheduler addPlan:spring to:<#Object#>];
In Swift:
let spring = TransitionSpring("<#key path#>",
transition: transition,
back: <#back value#>,
fore: <#fore value#>)
transition.scheduler.addPlan(spring, to: <#Layer#>)
We welcome contributions!
Check out our upcoming milestones.
Learn more about our team, our community, and our contributor essentials.
Licensed under the Apache 2.0 license. See LICENSE for details.