Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Motion
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Motion
Commits
8d2499ed
Unverified
Commit
8d2499ed
authored
Feb 03, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated UINavigationController to better detect motion options
parent
c35de387
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
4 deletions
+44
-4
Sources/Motion.swift
+44
-4
No files found.
Sources/Motion.swift
View file @
8d2499ed
...
...
@@ -151,6 +151,24 @@ extension UIViewController {
}
}
extension
UINavigationController
:
UINavigationControllerDelegate
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
delegate
=
self
}
@objc(navigationController:animationControllerForOperation:fromViewController:toViewController:)
open
func
navigationController
(
_
navigationController
:
UINavigationController
,
animationControllerFor
operation
:
UINavigationControllerOperation
,
from
fromVC
:
UIViewController
,
to
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
return
fromVC
.
isMotionEnabled
?
Motion
(
isPresenting
:
operation
==
.
push
)
:
nil
}
}
extension
UITabBarController
:
UITabBarControllerDelegate
{
open
func
tabBarController
(
_
tabBarController
:
UITabBarController
,
animationControllerForTransitionFrom
fromVC
:
UIViewController
,
to
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
return
fromVC
.
isMotionEnabled
?
Motion
()
:
nil
}
}
extension
UIView
{
/// MaterialTransitionItem Reference.
fileprivate
var
motionInstance
:
MotionInstance
{
...
...
@@ -394,6 +412,31 @@ open class Motion: NSObject {
open
class
func
cancel
(
delayed
completion
:
MotionDelayCancelBlock
)
{
completion
(
true
)
}
/**
Disables the default animations set on CALayers.
- Parameter animations: A callback that wraps the animations to disable.
*/
open
class
func
disable
(
_
animations
:
(()
->
Void
))
{
animate
(
duration
:
0
,
animations
:
animations
)
}
/**
Runs an animation with a specified duration.
- Parameter duration: An animation duration time.
- Parameter animations: An animation block.
- Parameter timingFunction: An MotionAnimationTimingFunction value.
- Parameter completion: A completion block that is executed once
the animations have completed.
*/
open
class
func
animate
(
duration
:
CFTimeInterval
,
timingFunction
:
MotionAnimationTimingFunction
=
.
easeInEaseOut
,
animations
:
(()
->
Void
),
completion
:
(()
->
Void
)?
=
nil
)
{
CATransaction
.
begin
()
CATransaction
.
setAnimationDuration
(
duration
)
CATransaction
.
setCompletionBlock
(
completion
)
CATransaction
.
setAnimationTimingFunction
(
MotionAnimationTimingFunctionToValue
(
timingFunction
:
timingFunction
))
animations
()
CATransaction
.
commit
()
}
}
extension
Motion
:
UIViewControllerAnimatedTransitioning
{
...
...
@@ -560,7 +603,7 @@ extension Motion {
- Parameter duration: An animation duration time for the group.
- Returns: A CAAnimationGroup.
*/
internal
class
func
animate
(
group
animations
:
[
CAAnimation
],
timingFunction
:
MotionAnimationTimingFunction
=
.
easeInEaseOut
,
duration
:
CFTimeInterval
=
0.5
)
->
CAAnimationGroup
{
open
class
func
animate
(
group
animations
:
[
CAAnimation
],
timingFunction
:
MotionAnimationTimingFunction
=
.
easeInEaseOut
,
duration
:
CFTimeInterval
=
0.5
)
->
CAAnimationGroup
{
let
group
=
CAAnimationGroup
()
group
.
fillMode
=
MotionAnimationFillModeToValue
(
mode
:
.
forwards
)
group
.
isRemovedOnCompletion
=
false
...
...
@@ -648,9 +691,6 @@ extension Motion {
fileprivate
func
clearTransitionView
()
{
transitionView
.
removeFromSuperview
()
transitionView
.
subviews
.
forEach
{
$0
.
removeFromSuperview
()
}
}
fileprivate
func
completeTransition
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment