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
54fc5fe5
Unverified
Commit
54fc5fe5
authored
Jun 14, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reverted changes to animator, plugin, and preprocessors that broke view controller level animations
parent
9e63ef52
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
92 deletions
+53
-92
Sources/Motion.swift
+1
-5
Sources/MotionController.swift
+52
-87
No files found.
Sources/Motion.swift
View file @
54fc5fe5
...
@@ -610,11 +610,7 @@ fileprivate extension Motion {
...
@@ -610,11 +610,7 @@ fileprivate extension Motion {
insertToViewFirst
=
true
insertToViewFirst
=
true
}
}
guard
let
a
=
animators
else
{
for
v
in
animators
{
return
}
for
v
in
a
{
(
v
as?
MotionHasInsertOrder
)?
.
insertToViewFirst
=
insertToViewFirst
(
v
as?
MotionHasInsertOrder
)?
.
insertToViewFirst
=
insertToViewFirst
}
}
}
}
...
...
Sources/MotionController.swift
View file @
54fc5fe5
...
@@ -107,16 +107,16 @@ public class MotionController: NSObject {
...
@@ -107,16 +107,16 @@ public class MotionController: NSObject {
internal
var
isFinished
=
true
internal
var
isFinished
=
true
/// An Array of MotionPreprocessors used during a transition.
/// An Array of MotionPreprocessors used during a transition.
internal
var
preprocessors
:
[
MotionPreprocessor
]
?
internal
var
preprocessors
:
[
MotionPreprocessor
]
!
/// An Array of MotionAnimators used during a transition.
/// An Array of MotionAnimators used during a transition.
internal
var
animators
:
[
MotionAnimator
]
?
internal
var
animators
:
[
MotionAnimator
]
!
/// An Array of MotionPlugins used during a transition.
/// An Array of MotionPlugins used during a transition.
internal
var
plugins
:
[
MotionPlugin
]
?
internal
var
plugins
:
[
MotionPlugin
]
!
/// The matching fromViews to toViews based on the motionIdentifier value.
/// The matching fromViews to toViews based on the motionIdentifier value.
internal
var
transitionPairs
:
[(
fromViews
:
[
UIView
],
toViews
:
[
UIView
])]
?
internal
var
transitionPairs
:
[(
fromViews
:
[
UIView
],
toViews
:
[
UIView
])]
!
/// Plugins that are enabled during the transition.
/// Plugins that are enabled during the transition.
internal
static
var
enabledPlugins
=
[
MotionPlugin
.
Type
]()
internal
static
var
enabledPlugins
=
[
MotionPlugin
.
Type
]()
...
@@ -154,27 +154,17 @@ fileprivate extension MotionController {
...
@@ -154,27 +154,17 @@ fileprivate extension MotionController {
/// Updates the animators.
/// Updates the animators.
func
updateAnimators
()
{
func
updateAnimators
()
{
guard
let
a
=
animators
else
{
let
t
=
elapsedTime
*
totalDuration
return
for
a
in
animators
{
}
a
.
seek
(
to
:
t
)
let
v
=
elapsedTime
*
totalDuration
for
x
in
a
{
x
.
seek
(
to
:
v
)
}
}
}
}
/// Updates the plugins.
/// Updates the plugins.
func
updatePlugins
()
{
func
updatePlugins
()
{
guard
let
p
=
plugins
else
{
let
t
=
elapsedTime
*
totalDuration
return
for
p
in
plugins
where
p
.
requirePerFrameCallback
{
}
p
.
seek
(
to
:
t
)
let
v
=
elapsedTime
*
totalDuration
for
plugin
in
p
where
plugin
.
requirePerFrameCallback
{
plugin
.
seek
(
to
:
v
)
}
}
}
}
}
}
...
@@ -249,15 +239,13 @@ public extension MotionController {
...
@@ -249,15 +239,13 @@ public extension MotionController {
return
return
}
}
var
v
:
TimeInterval
=
0
var
t
:
TimeInterval
=
0
if
let
a
=
animators
{
for
a
in
animators
{
for
x
in
a
{
t
=
max
(
t
,
a
.
resume
(
at
:
elapsedTime
*
totalDuration
,
isReversed
:
false
))
v
=
max
(
v
,
x
.
resume
(
at
:
elapsedTime
*
totalDuration
,
isReversed
:
false
))
}
}
}
complete
(
after
:
v
,
isFinished
:
true
)
complete
(
after
:
t
,
isFinished
:
true
)
}
}
/**
/**
...
@@ -276,21 +264,18 @@ public extension MotionController {
...
@@ -276,21 +264,18 @@ public extension MotionController {
return
return
}
}
var
v
:
TimeInterval
=
0
var
d
:
TimeInterval
=
0
if
let
a
=
animators
{
for
a
in
animators
{
for
x
in
a
{
var
t
=
elapsedTime
var
t
=
elapsedTime
if
t
<
0
{
if
t
<
0
{
t
=
-
t
t
=
-
t
}
}
v
=
max
(
v
,
x
.
resume
(
at
:
t
*
totalDuration
,
isReversed
:
true
))
d
=
max
(
d
,
a
.
resume
(
at
:
t
*
totalDuration
,
isReversed
:
true
))
}
}
}
complete
(
after
:
v
,
isFinished
:
false
)
complete
(
after
:
d
,
isFinished
:
false
)
}
}
/**
/**
...
@@ -309,15 +294,11 @@ public extension MotionController {
...
@@ -309,15 +294,11 @@ 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
for
x
in
a
{
for
a
in
animators
{
x
.
apply
(
state
:
s
,
to
:
v
)
a
.
apply
(
state
:
s
,
to
:
v
)
}
}
}
}
}
}
...
@@ -349,20 +330,16 @@ internal extension MotionController {
...
@@ -349,20 +330,16 @@ internal extension MotionController {
transitionPairs
=
[([
UIView
],
[
UIView
])]()
transitionPairs
=
[([
UIView
],
[
UIView
])]()
guard
let
a
=
animators
else
{
for
a
in
animators
{
return
let
fv
=
context
.
fromViews
.
filter
{
(
view
:
UIView
)
->
Bool
in
}
return
a
.
canAnimate
(
view
:
view
,
isAppearing
:
false
)
for
x
in
a
{
let
fv
=
context
.
fromViews
.
filter
{
return
x
.
canAnimate
(
view
:
$0
,
isAppearing
:
false
)
}
}
let
tv
=
context
.
toViews
.
filter
{
let
tv
=
context
.
toViews
.
filter
{
return
x
.
canAnimate
(
view
:
$0
,
isAppearing
:
true
)
return
a
.
canAnimate
(
view
:
$0
,
isAppearing
:
true
)
}
}
transitionPairs
?
.
append
((
fv
,
tv
))
transitionPairs
.
append
((
fv
,
tv
))
}
}
}
}
}
}
...
@@ -374,12 +351,8 @@ internal extension MotionController {
...
@@ -374,12 +351,8 @@ internal extension MotionController {
return
return
}
}
guard
let
p
=
preprocessors
else
{
for
v
in
preprocessors
{
return
v
.
process
(
fromViews
:
context
.
fromViews
,
toViews
:
context
.
toViews
)
}
for
x
in
p
{
x
.
process
(
fromViews
:
context
.
fromViews
,
toViews
:
context
.
toViews
)
}
}
}
}
...
@@ -392,32 +365,28 @@ internal extension MotionController {
...
@@ -392,32 +365,28 @@ internal extension MotionController {
return
return
}
}
if
let
tp
=
transitionPairs
{
for
(
fv
,
tv
)
in
transitionPairs
{
for
x
in
tp
{
for
view
in
fv
{
for
v
in
x
.
fromViews
{
context
.
hide
(
view
:
view
)
context
.
hide
(
view
:
v
)
}
}
for
v
in
x
.
toViews
{
for
view
in
tv
{
context
.
hide
(
view
:
v
)
context
.
hide
(
view
:
view
)
}
}
}
}
}
var
t
:
TimeInterval
=
0
var
t
:
TimeInterval
=
0
var
b
=
false
var
b
=
false
if
let
a
=
animators
,
let
tp
=
transitionPairs
{
for
(
i
,
a
)
in
animators
.
enumerated
()
{
for
(
i
,
x
)
in
a
.
enumerated
()
{
let
d
=
a
.
animate
(
fromViews
:
transitionPairs
[
i
]
.
0
,
toViews
:
transitionPairs
[
i
]
.
1
)
let
d
=
x
.
animate
(
fromViews
:
tp
[
i
]
.
0
,
toViews
:
tp
[
i
]
.
1
)
if
d
==
.
infinity
{
if
.
infinity
==
d
{
b
=
true
b
=
true
}
else
{
}
else
{
t
=
max
(
t
,
d
)
t
=
max
(
t
,
d
)
}
}
}
}
}
totalDuration
=
t
totalDuration
=
t
...
@@ -458,13 +427,18 @@ internal extension MotionController {
...
@@ -458,13 +427,18 @@ internal extension MotionController {
has completed.
has completed.
*/
*/
func
complete
(
isFinished
:
Bool
)
{
func
complete
(
isFinished
:
Bool
)
{
defer
{
guard
isTransitioning
else
{
animators
?
.
forEach
{
return
$0
.
clean
()
}
for
a
in
animators
{
a
.
clean
()
}
}
transitionContainer
?
.
isUserInteractionEnabled
=
true
transitionContainer
?
.
isUserInteractionEnabled
=
true
let
completion
=
completionCallback
transitionPairs
=
nil
transitionPairs
=
nil
transitionObservers
=
nil
transitionObservers
=
nil
transitionContainer
=
nil
transitionContainer
=
nil
...
@@ -477,13 +451,8 @@ internal extension MotionController {
...
@@ -477,13 +451,8 @@ internal extension MotionController {
beginTime
=
nil
beginTime
=
nil
elapsedTime
=
0
elapsedTime
=
0
totalDuration
=
0
totalDuration
=
0
}
guard
isTransitioning
else
{
completion
?(
isFinished
)
return
}
completionCallback
?(
isFinished
)
}
}
}
}
...
@@ -520,7 +489,7 @@ fileprivate extension MotionController {
...
@@ -520,7 +489,7 @@ fileprivate extension MotionController {
DurationPreprocessor
()
DurationPreprocessor
()
]
]
for
v
in
preprocessors
!
{
for
v
in
preprocessors
{
v
.
context
=
context
v
.
context
=
context
}
}
}
}
...
@@ -532,10 +501,10 @@ fileprivate extension MotionController {
...
@@ -532,10 +501,10 @@ fileprivate extension MotionController {
]
]
if
#available(iOS 10, tvOS 10, *)
{
if
#available(iOS 10, tvOS 10, *)
{
animators
?
.
append
(
MotionDefaultAnimator
<
MotionViewPropertyViewContext
>
())
animators
.
append
(
MotionDefaultAnimator
<
MotionViewPropertyViewContext
>
())
}
}
for
v
in
animators
!
{
for
v
in
animators
{
v
.
context
=
context
v
.
context
=
context
}
}
}
}
...
@@ -546,9 +515,9 @@ fileprivate extension MotionController {
...
@@ -546,9 +515,9 @@ fileprivate extension MotionController {
return
$0
.
init
()
return
$0
.
init
()
})
})
for
plugin
in
plugins
!
{
for
plugin
in
plugins
{
preprocessors
?
.
append
(
plugin
)
preprocessors
.
append
(
plugin
)
animators
?
.
append
(
plugin
)
animators
.
append
(
plugin
)
}
}
}
}
}
}
...
@@ -588,12 +557,8 @@ internal extension MotionController {
...
@@ -588,12 +557,8 @@ internal extension MotionController {
internal
extension
MotionController
{
internal
extension
MotionController
{
// should call this after `prepareTransitionPairs` & before `processContext`
// should call this after `prepareTransitionPairs` & before `processContext`
func
insert
<
T
>
(
preprocessor
:
MotionPreprocessor
,
before
:
T
.
Type
)
{
func
insert
<
T
>
(
preprocessor
:
MotionPreprocessor
,
before
:
T
.
Type
)
{
guard
var
p
=
preprocessors
else
{
let
i
=
preprocessors
.
index
{
$0
is
T
}
??
preprocessors
.
count
return
}
let
i
=
p
.
index
{
$0
is
T
}
??
p
.
count
preprocessor
.
context
=
context
preprocessor
.
context
=
context
p
.
insert
(
preprocessor
,
at
:
i
)
p
reprocessors
.
insert
(
preprocessor
,
at
:
i
)
}
}
}
}
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