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
5653affe
Unverified
Commit
5653affe
authored
Jun 11, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reworked SourcePreprocessor
parent
63316063
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
11 deletions
+37
-11
Sources/Preprocessors/SourcePreprocessor.swift
+37
-11
No files found.
Sources/Preprocessors/SourcePreprocessor.swift
View file @
5653affe
...
@@ -32,28 +32,45 @@ class SourcePreprocessor: MotionPreprocessor {
...
@@ -32,28 +32,45 @@ class SourcePreprocessor: MotionPreprocessor {
/// A reference to a MotionContext.
/// A reference to a MotionContext.
weak
var
context
:
MotionContext
!
weak
var
context
:
MotionContext
!
func
process
(
fromViews
:
[
UIView
],
toViews
:
[
UIView
])
{
/**
Processes the transitionary views.
- Parameter fromViews: An Array of UIViews.
- Parameter toViews: An Array of UIViews.
*/
func
process
(
fromViews
:
[
UIView
],
toViews
:
[
UIView
])
{
for
fv
in
fromViews
{
for
fv
in
fromViews
{
guard
let
id
=
context
[
fv
]?
.
motionIdentifier
,
guard
let
i
=
context
[
fv
]?
.
motionIdentifier
,
let
tv
=
context
.
destinationView
(
for
:
i
)
else
{
let
tv
=
context
.
destinationView
(
for
:
id
)
else
{
continue
}
continue
prepareFor
(
view
:
fv
,
targetView
:
tv
)
}
prepare
(
view
:
fv
,
for
:
tv
)
}
}
for
tv
in
toViews
{
for
tv
in
toViews
{
guard
let
id
=
context
[
tv
]?
.
motionIdentifier
,
guard
let
i
=
context
[
tv
]?
.
motionIdentifier
,
let
fv
=
context
.
sourceView
(
for
:
i
)
else
{
let
fv
=
context
.
sourceView
(
for
:
id
)
else
{
continue
}
continue
prepareFor
(
view
:
tv
,
targetView
:
fv
)
}
prepare
(
view
:
tv
,
for
:
fv
)
}
}
}
}
func
prepareFor
(
view
:
UIView
,
targetView
:
UIView
)
{
/**
Prepares a given view for a target view.
- Parameter view: A UIView.
- Parameter for targetView: A UIView.
*/
func
prepare
(
view
:
UIView
,
for
targetView
:
UIView
)
{
let
targetPos
=
context
.
container
.
convert
(
targetView
.
layer
.
position
,
from
:
targetView
.
superview
!
)
let
targetPos
=
context
.
container
.
convert
(
targetView
.
layer
.
position
,
from
:
targetView
.
superview
!
)
var
state
=
context
[
view
]
!
var
state
=
context
[
view
]
!
// use global coordinate space since over target position is converted from the global container
/**
Use global coordinate space since over target position is
converted from the global container
*/
state
.
coordinateSpace
=
.
global
state
.
coordinateSpace
=
.
global
// remove incompatible options
// Remove incompatible options.
state
.
position
=
targetPos
state
.
position
=
targetPos
state
.
transform
=
nil
state
.
transform
=
nil
state
.
size
=
nil
state
.
size
=
nil
...
@@ -62,30 +79,39 @@ func process(fromViews: [UIView], toViews: [UIView]) {
...
@@ -62,30 +79,39 @@ func process(fromViews: [UIView], toViews: [UIView]) {
if
view
.
bounds
.
size
!=
targetView
.
bounds
.
size
{
if
view
.
bounds
.
size
!=
targetView
.
bounds
.
size
{
state
.
size
=
targetView
.
bounds
.
size
state
.
size
=
targetView
.
bounds
.
size
}
}
if
view
.
layer
.
cornerRadius
!=
targetView
.
layer
.
cornerRadius
{
if
view
.
layer
.
cornerRadius
!=
targetView
.
layer
.
cornerRadius
{
state
.
cornerRadius
=
targetView
.
layer
.
cornerRadius
state
.
cornerRadius
=
targetView
.
layer
.
cornerRadius
}
}
if
view
.
layer
.
transform
!=
targetView
.
layer
.
transform
{
if
view
.
layer
.
transform
!=
targetView
.
layer
.
transform
{
state
.
transform
=
targetView
.
layer
.
transform
state
.
transform
=
targetView
.
layer
.
transform
}
}
if
view
.
layer
.
shadowColor
!=
targetView
.
layer
.
shadowColor
{
if
view
.
layer
.
shadowColor
!=
targetView
.
layer
.
shadowColor
{
state
.
shadowColor
=
targetView
.
layer
.
shadowColor
state
.
shadowColor
=
targetView
.
layer
.
shadowColor
}
}
if
view
.
layer
.
shadowOpacity
!=
targetView
.
layer
.
shadowOpacity
{
if
view
.
layer
.
shadowOpacity
!=
targetView
.
layer
.
shadowOpacity
{
state
.
shadowOpacity
=
targetView
.
layer
.
shadowOpacity
state
.
shadowOpacity
=
targetView
.
layer
.
shadowOpacity
}
}
if
view
.
layer
.
shadowOffset
!=
targetView
.
layer
.
shadowOffset
{
if
view
.
layer
.
shadowOffset
!=
targetView
.
layer
.
shadowOffset
{
state
.
shadowOffset
=
targetView
.
layer
.
shadowOffset
state
.
shadowOffset
=
targetView
.
layer
.
shadowOffset
}
}
if
view
.
layer
.
shadowRadius
!=
targetView
.
layer
.
shadowRadius
{
if
view
.
layer
.
shadowRadius
!=
targetView
.
layer
.
shadowRadius
{
state
.
shadowRadius
=
targetView
.
layer
.
shadowRadius
state
.
shadowRadius
=
targetView
.
layer
.
shadowRadius
}
}
if
view
.
layer
.
shadowPath
!=
targetView
.
layer
.
shadowPath
{
if
view
.
layer
.
shadowPath
!=
targetView
.
layer
.
shadowPath
{
state
.
shadowPath
=
targetView
.
layer
.
shadowPath
state
.
shadowPath
=
targetView
.
layer
.
shadowPath
}
}
if
view
.
layer
.
contentsRect
!=
targetView
.
layer
.
contentsRect
{
if
view
.
layer
.
contentsRect
!=
targetView
.
layer
.
contentsRect
{
state
.
contentsRect
=
targetView
.
layer
.
contentsRect
state
.
contentsRect
=
targetView
.
layer
.
contentsRect
}
}
if
view
.
layer
.
contentsScale
!=
targetView
.
layer
.
contentsScale
{
if
view
.
layer
.
contentsScale
!=
targetView
.
layer
.
contentsScale
{
state
.
contentsScale
=
targetView
.
layer
.
contentsScale
state
.
contentsScale
=
targetView
.
layer
.
contentsScale
}
}
...
...
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