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
426a8998
Unverified
Commit
426a8998
authored
Jun 11, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reworked CascadePreprocessor
parent
6df970aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
32 deletions
+43
-32
Sources/Preprocessors/CascadePreprocessor.swift
+40
-29
Sources/TransitionPreprocessor.swift
+3
-3
No files found.
Sources/Preprocessors/CascadePreprocessor.swift
View file @
426a8998
...
@@ -36,6 +36,7 @@ public enum CascadeDirection {
...
@@ -36,6 +36,7 @@ public enum CascadeDirection {
case
radial
(
center
:
CGPoint
)
case
radial
(
center
:
CGPoint
)
case
inverseRadial
(
center
:
CGPoint
)
case
inverseRadial
(
center
:
CGPoint
)
/// Based on the cascade direction a comparator is set.
var
comparator
:
(
UIView
,
UIView
)
->
Bool
{
var
comparator
:
(
UIView
,
UIView
)
->
Bool
{
switch
self
{
switch
self
{
case
.
topToBottom
:
case
.
topToBottom
:
...
@@ -63,42 +64,52 @@ class CascadePreprocessor: MotionPreprocessor {
...
@@ -63,42 +64,52 @@ class CascadePreprocessor: MotionPreprocessor {
/// A reference to a MotionContext.
/// A reference to a MotionContext.
weak
var
context
:
MotionContext
!
weak
var
context
:
MotionContext
!
/**
Processes the from-views and to-views.
- Parameter fromViews: An Array of UIViews.
- Parameter toViews: An Array of UIViews.
*/
func
process
(
fromViews
:
[
UIView
],
toViews
:
[
UIView
])
{
func
process
(
fromViews
:
[
UIView
],
toViews
:
[
UIView
])
{
process
(
views
:
fromViews
)
process
(
views
:
fromViews
)
process
(
views
:
toViews
)
process
(
views
:
toViews
)
}
}
func
process
(
views
:
[
UIView
])
{
/**
for
view
in
views
{
Process an Array of views for the cascade animation.
guard
let
(
deltaTime
,
direction
,
delayMatchedViews
)
=
context
[
view
]?
.
cascade
else
{
continue
}
- Parameter views: An Array of UIViews.
*/
func
process
(
views
:
[
UIView
])
{
for
v
in
views
{
guard
let
(
deltaTime
,
direction
,
delayMatchedViews
)
=
context
[
v
]?
.
cascade
else
{
continue
}
var
parentView
=
view
var
parentView
=
v
is
UITableView
?
v
.
subviews
.
get
(
0
)
??
v
:
v
if
view
is
UITableView
,
let
wrapperView
=
view
.
subviews
.
get
(
0
)
{
parentView
=
wrapperView
}
let
sortedSubviews
=
parentView
.
subviews
.
sorted
(
by
:
direction
.
comparator
)
let
sortedSubviews
=
parentView
.
subviews
.
sorted
(
by
:
direction
.
comparator
)
let
initialDelay
=
context
[
view
]
!.
delay
let
initialDelay
=
context
[
v
]
!.
delay
let
finalDelay
=
TimeInterval
(
sortedSubviews
.
count
)
*
deltaTime
+
initialDelay
let
finalDelay
=
TimeInterval
(
sortedSubviews
.
count
)
*
deltaTime
+
initialDelay
for
(
i
,
subview
)
in
sortedSubviews
.
enumerated
()
{
for
(
i
,
subview
)
in
sortedSubviews
.
enumerated
()
{
let
delay
=
TimeInterval
(
i
)
*
deltaTime
+
initialDelay
let
delay
=
TimeInterval
(
i
)
*
deltaTime
+
initialDelay
func
applyDelay
(
view
:
UIView
)
{
func
applyDelay
(
view
:
UIView
)
{
if
context
.
transitionPairedView
(
for
:
view
)
==
nil
{
if
context
.
transitionPairedView
(
for
:
view
)
==
nil
{
context
[
view
]?
.
delay
=
delay
context
[
view
]?
.
delay
=
delay
}
else
if
delayMatchedViews
,
let
paired
=
context
.
transitionPairedView
(
for
:
view
)
{
context
[
view
]?
.
delay
=
finalDelay
}
else
if
delayMatchedViews
,
let
paired
=
context
.
transitionPairedView
(
for
:
view
)
{
context
[
paired
]?
.
delay
=
finalDelay
context
[
view
]?
.
delay
=
finalDelay
}
context
[
paired
]?
.
delay
=
finalDelay
for
subview
in
view
.
subviews
{
}
applyDelay
(
view
:
subview
)
}
for
subview
in
view
.
subviews
{
}
applyDelay
(
view
:
subview
)
}
}
applyDelay
(
view
:
subview
)
applyDelay
(
view
:
subview
)
}
}
}
}
}
}
}
}
Sources/TransitionPreprocessor.swift
View file @
426a8998
...
@@ -173,15 +173,15 @@ public enum MotionTransitionType {
...
@@ -173,15 +173,15 @@ public enum MotionTransitionType {
}
}
class
TransitionPreprocessor
:
MotionPreprocessor
{
class
TransitionPreprocessor
:
MotionPreprocessor
{
/// A reference to a MotionContext
instance
.
/// A reference to a MotionContext.
weak
var
context
:
MotionContext
!
weak
var
context
:
MotionContext
!
/// A reference to a Motion
instance
.
/// A reference to a Motion.
weak
var
motion
:
Motion
?
weak
var
motion
:
Motion
?
/**
/**
An initializer that accepts a given Motion instance.
An initializer that accepts a given Motion instance.
- Parameter motion: A Motion
instance
.
- Parameter motion: A Motion.
*/
*/
init
(
motion
:
Motion
)
{
init
(
motion
:
Motion
)
{
self
.
motion
=
motion
self
.
motion
=
motion
...
...
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