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
d7a293b6
Unverified
Commit
d7a293b6
authored
Jun 13, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated handling of optionals with guards and ifs rather than blocks
parent
02256789
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
19 deletions
+28
-19
Sources/MotionController.swift
+28
-19
No files found.
Sources/MotionController.swift
View file @
d7a293b6
...
@@ -154,10 +154,14 @@ fileprivate extension MotionController {
...
@@ -154,10 +154,14 @@ fileprivate extension MotionController {
/// Updates the animators.
/// Updates the animators.
func
updateAnimators
()
{
func
updateAnimators
()
{
guard
let
a
=
animators
else
{
return
}
let
v
=
elapsedTime
*
totalDuration
let
v
=
elapsedTime
*
totalDuration
animators
?
.
forEach
{
for
x
in
a
{
$0
.
seek
(
to
:
v
)
x
.
seek
(
to
:
v
)
}
}
}
}
...
@@ -246,8 +250,11 @@ public extension MotionController {
...
@@ -246,8 +250,11 @@ public extension MotionController {
}
}
var
v
:
TimeInterval
=
0
var
v
:
TimeInterval
=
0
animators
?
.
forEach
{
v
=
max
(
v
,
$0
.
resume
(
at
:
elapsedTime
*
totalDuration
,
isReversed
:
false
))
if
let
a
=
animators
{
for
x
in
a
{
v
=
max
(
v
,
x
.
resume
(
at
:
elapsedTime
*
totalDuration
,
isReversed
:
false
))
}
}
}
complete
(
after
:
v
,
isFinished
:
true
)
complete
(
after
:
v
,
isFinished
:
true
)
...
@@ -304,11 +311,15 @@ public extension MotionController {
...
@@ -304,11 +311,15 @@ public extension MotionController {
return
return
}
}
guard
let
a
=
animators
else
{
return
}
let
s
=
MotionTransitionState
(
transitions
:
transitions
)
let
s
=
MotionTransitionState
(
transitions
:
transitions
)
let
v
=
context
.
transitionPairedView
(
for
:
view
)
??
view
let
v
=
context
.
transitionPairedView
(
for
:
view
)
??
view
animators
?
.
forEach
{
for
x
in
a
{
$0
.
apply
(
state
:
s
,
to
:
v
)
x
.
apply
(
state
:
s
,
to
:
v
)
}
}
}
}
}
}
...
@@ -362,15 +373,15 @@ internal extension MotionController {
...
@@ -362,15 +373,15 @@ internal extension MotionController {
/// Executes the preprocessors' process function.
/// Executes the preprocessors' process function.
func
processContext
()
{
func
processContext
()
{
guard
isTransitioning
else
{
guard
isTransitioning
else
{
fatalError
()
return
}
}
preprocessors
?
.
forEach
{
[
weak
self
]
in
guard
let
p
=
preprocessors
else
{
guard
let
s
=
self
else
{
return
return
}
}
$0
.
process
(
fromViews
:
s
.
context
.
fromViews
,
toViews
:
s
.
context
.
toViews
)
for
x
in
p
{
x
.
process
(
fromViews
:
context
.
fromViews
,
toViews
:
context
.
toViews
)
}
}
}
}
...
@@ -380,20 +391,20 @@ internal extension MotionController {
...
@@ -380,20 +391,20 @@ internal extension MotionController {
*/
*/
func
animate
()
{
func
animate
()
{
guard
isTransitioning
else
{
guard
isTransitioning
else
{
fatalError
()
return
}
}
transitionPairs
?
.
forEach
{
[
weak
self
]
in
guard
let
tp
=
transitionPairs
else
{
guard
let
s
=
self
else
{
return
return
}
}
for
view
in
$0
.
fromViews
{
for
x
in
tp
{
s
.
context
.
hide
(
view
:
view
)
for
v
in
x
.
fromViews
{
context
.
hide
(
view
:
v
)
}
}
for
v
iew
in
$0
.
toViews
{
for
v
in
x
.
toViews
{
s
.
context
.
hide
(
view
:
view
)
context
.
hide
(
view
:
v
)
}
}
}
}
...
@@ -402,8 +413,6 @@ internal extension MotionController {
...
@@ -402,8 +413,6 @@ internal extension MotionController {
if
let
a
=
animators
,
let
tp
=
transitionPairs
{
if
let
a
=
animators
,
let
tp
=
transitionPairs
{
for
(
i
,
x
)
in
a
.
enumerated
()
{
for
(
i
,
x
)
in
a
.
enumerated
()
{
let
d
=
x
.
animate
(
fromViews
:
tp
[
i
]
.
0
,
toViews
:
tp
[
i
]
.
1
)
let
d
=
x
.
animate
(
fromViews
:
tp
[
i
]
.
0
,
toViews
:
tp
[
i
]
.
1
)
if
d
==
.
infinity
{
if
d
==
.
infinity
{
...
...
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