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
aa31695e
Unverified
Commit
aa31695e
authored
Jun 08, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished MotionController and Motion rework
parent
3e422773
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
19 deletions
+33
-19
Sources/MotionController.swift
+33
-19
No files found.
Sources/MotionController.swift
View file @
aa31695e
...
@@ -347,6 +347,7 @@ internal extension MotionController {
...
@@ -347,6 +347,7 @@ internal extension MotionController {
}
}
internal
extension
MotionController
{
internal
extension
MotionController
{
/// Executes the preprocessors' process function.
func
processContext
()
{
func
processContext
()
{
guard
isTransitioning
else
{
guard
isTransitioning
else
{
fatalError
()
fatalError
()
...
@@ -357,45 +358,53 @@ internal extension MotionController {
...
@@ -357,45 +358,53 @@ internal extension MotionController {
}
}
}
}
/// Actually animate the views
/**
/// subclass should call `prepareTransition` & `prepareTransitionPairs` before calling `animate`
Animates the views. Subclasses should call `prepareTransition` &
`prepareTransitionPairs` before calling `animate`.
*/
func
animate
()
{
func
animate
()
{
guard
isTransitioning
else
{
guard
isTransitioning
else
{
fatalError
()
fatalError
()
}
}
for
(
currentFromViews
,
currentToViews
)
in
transitionPairs
{
for
(
fv
,
tv
)
in
transitionPairs
{
// auto hide all animated views
for
view
in
fv
{
for
view
in
currentFromViews
{
context
.
hide
(
view
:
view
)
context
.
hide
(
view
:
view
)
}
}
for
view
in
currentToViews
{
for
view
in
tv
{
context
.
hide
(
view
:
view
)
context
.
hide
(
view
:
view
)
}
}
}
}
var
t
otalDuration
:
TimeInterval
=
0
var
t
:
TimeInterval
=
0
var
animatorWantsInteractive
=
false
var
v
=
false
for
(
i
,
a
nimator
)
in
animators
.
enumerated
()
{
for
(
i
,
a
)
in
animators
.
enumerated
()
{
let
d
uration
=
animator
.
animate
(
fromViews
:
transitionPairs
[
i
]
.
0
,
toViews
:
transitionPairs
[
i
]
.
1
)
let
d
=
a
.
animate
(
fromViews
:
transitionPairs
[
i
]
.
0
,
toViews
:
transitionPairs
[
i
]
.
1
)
if
d
uration
==
.
infinity
{
if
d
==
.
infinity
{
animatorWantsInteractive
=
true
v
=
true
}
else
{
}
else
{
t
otalDuration
=
max
(
totalDuration
,
duration
)
t
=
max
(
t
,
d
)
}
}
}
}
self
.
totalDuration
=
totalDuration
totalDuration
=
t
if
animatorWantsInteractive
{
if
v
{
update
(
elapsedTime
:
0
)
update
(
elapsedTime
:
0
)
}
else
{
}
else
{
complete
(
after
:
t
otalDuration
,
isFinished
:
true
)
complete
(
after
:
t
,
isFinished
:
true
)
}
}
}
}
/**
Complete the transition.
- Parameter after: A TimeInterval.
- Parameter isFinished: A Boolean indicating if the transition
has completed.
*/
func
complete
(
after
:
TimeInterval
,
isFinished
:
Bool
)
{
func
complete
(
after
:
TimeInterval
,
isFinished
:
Bool
)
{
guard
isTransitioning
else
{
guard
isTransitioning
else
{
fatalError
()
fatalError
()
...
@@ -412,16 +421,21 @@ internal extension MotionController {
...
@@ -412,16 +421,21 @@ internal extension MotionController {
self
.
beginTime
=
CACurrentMediaTime
()
-
v
self
.
beginTime
=
CACurrentMediaTime
()
-
v
}
}
/**
Complete the transition.
- Parameter isFinished: A Boolean indicating if the transition
has completed.
*/
func
complete
(
isFinished
:
Bool
)
{
func
complete
(
isFinished
:
Bool
)
{
guard
isTransitioning
else
{
guard
isTransitioning
else
{
fatalError
()
fatalError
()
}
}
for
a
nimator
in
animators
{
for
a
in
animators
{
a
nimator
.
clean
()
a
.
clean
()
}
}
transitionContainer
!
.
isUserInteractionEnabled
=
true
transitionContainer
?
.
isUserInteractionEnabled
=
true
let
completion
=
completionCallback
let
completion
=
completionCallback
...
...
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