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
5dc54456
Commit
5dc54456
authored
May 29, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added clean functions for current transition properties
parent
21a473d7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
15 deletions
+20
-15
Sources/MotionController.swift
+20
-15
No files found.
Sources/MotionController.swift
View file @
5dc54456
...
@@ -52,18 +52,18 @@ open class MotionController: NSObject, MotionSubscriber {
...
@@ -52,18 +52,18 @@ open class MotionController: NSObject, MotionSubscriber {
}
}
/// A reference to the animation duration.
/// A reference to the animation duration.
fileprivate
var
anima
tionDuration
:
TimeInterval
=
0
fileprivate
var
transi
tionDuration
:
TimeInterval
=
0
/**
/**
A reference to the animation total duration,
A reference to the animation total duration,
which is the total running animation time.
which is the total running animation time.
*/
*/
fileprivate
var
anima
tionTotalDuration
:
TimeInterval
=
0
fileprivate
var
transi
tionTotalDuration
:
TimeInterval
=
0
/// A reference to the animation start time.
/// A reference to the animation start time.
fileprivate
var
anima
tionStartTime
:
TimeInterval
?
{
fileprivate
var
transi
tionStartTime
:
TimeInterval
?
{
didSet
{
didSet
{
guard
nil
!=
anima
tionStartTime
else
{
guard
nil
!=
transi
tionStartTime
else
{
displayLink
=
nil
displayLink
=
nil
return
return
}
}
...
@@ -77,7 +77,7 @@ open class MotionController: NSObject, MotionSubscriber {
...
@@ -77,7 +77,7 @@ open class MotionController: NSObject, MotionSubscriber {
}
}
/// A reference to the animation elapsed time.
/// A reference to the animation elapsed time.
open
fileprivate
(
set
)
var
anima
tionElapsedTime
:
TimeInterval
=
0
{
open
fileprivate
(
set
)
var
transi
tionElapsedTime
:
TimeInterval
=
0
{
didSet
{
didSet
{
guard
isTransitioning
else
{
guard
isTransitioning
else
{
return
return
...
@@ -107,8 +107,11 @@ open class MotionController: NSObject, MotionSubscriber {
...
@@ -107,8 +107,11 @@ open class MotionController: NSObject, MotionSubscriber {
return
nil
==
displayLink
return
nil
==
displayLink
}
}
///
UIKit's supplied t
ransition container.
///
T
ransition container.
open
fileprivate
(
set
)
var
transitionContainer
:
UIView
!
open
fileprivate
(
set
)
var
transitionContainer
:
UIView
!
/// An Array of from and to view paris to be animated.
open
fileprivate
(
set
)
var
transitionParis
=
[(
fromViews
:
[
UIView
],
toViews
:
[
UIView
])]()
}
}
extension
MotionController
{
extension
MotionController
{
...
@@ -122,28 +125,28 @@ extension MotionController {
...
@@ -122,28 +125,28 @@ extension MotionController {
return
return
}
}
guard
0
<
anima
tionDuration
else
{
guard
0
<
transi
tionDuration
else
{
return
return
}
}
guard
let
v
=
anima
tionStartTime
else
{
guard
let
v
=
transi
tionStartTime
else
{
return
return
}
}
var
elapsedTime
=
CACurrentMediaTime
()
-
v
var
elapsedTime
=
CACurrentMediaTime
()
-
v
if
elapsedTime
>
anima
tionDuration
{
if
elapsedTime
>
transi
tionDuration
{
anima
tionElapsedTime
=
isFinished
?
1
:
0
transi
tionElapsedTime
=
isFinished
?
1
:
0
completeTransition
()
completeTransition
()
}
else
{
}
else
{
elapsedTime
=
elapsedTime
/
anima
tionDuration
elapsedTime
=
elapsedTime
/
transi
tionDuration
if
!
isFinished
{
if
!
isFinished
{
elapsedTime
=
1
-
elapsedTime
elapsedTime
=
1
-
elapsedTime
}
}
anima
tionElapsedTime
=
max
(
0
,
min
(
1
,
elapsedTime
))
transi
tionElapsedTime
=
max
(
0
,
min
(
1
,
elapsedTime
))
}
}
}
}
}
}
...
@@ -151,13 +154,13 @@ extension MotionController {
...
@@ -151,13 +154,13 @@ extension MotionController {
extension
MotionController
{
extension
MotionController
{
fileprivate
func
updateMotionObservers
()
{
fileprivate
func
updateMotionObservers
()
{
for
v
in
observers
{
for
v
in
observers
{
v
.
update
(
elapsedTime
:
anima
tionElapsedTime
)
v
.
update
(
elapsedTime
:
transi
tionElapsedTime
)
}
}
}
}
/// Updates the motion animators.
/// Updates the motion animators.
fileprivate
func
updateMotionAnimators
()
{
fileprivate
func
updateMotionAnimators
()
{
let
elapsedTime
=
animationElapsedTime
*
anima
tionTotalDuration
let
elapsedTime
=
transitionElapsedTime
*
transi
tionTotalDuration
for
v
in
animators
{
for
v
in
animators
{
v
.
seekTo
(
elapsedTime
:
elapsedTime
)
v
.
seekTo
(
elapsedTime
:
elapsedTime
)
...
@@ -181,6 +184,8 @@ extension MotionController {
...
@@ -181,6 +184,8 @@ extension MotionController {
/// Cleans the transition values.
/// Cleans the transition values.
fileprivate
func
cleanTransitionValues
()
{
fileprivate
func
cleanTransitionValues
()
{
animationStartTime
=
nil
transitionStartTime
=
nil
transitionElapsedTime
=
0
transitionTotalDuration
=
0
}
}
}
}
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