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
a0a1e257
Unverified
Commit
a0a1e257
authored
Jun 10, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reworked MotionTransition
parent
4375ba87
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
57 deletions
+55
-57
Sources/MotionContext.swift
+3
-3
Sources/MotionSnapshotType.swift
+1
-1
Sources/MotionTransition.swift
+51
-53
No files found.
Sources/MotionContext.swift
View file @
a0a1e257
...
@@ -207,7 +207,7 @@ public extension MotionContext {
...
@@ -207,7 +207,7 @@ public extension MotionContext {
case
.
layerRender
:
case
.
layerRender
:
snapshot
=
view
.
slowSnapshotView
()
snapshot
=
view
.
slowSnapshotView
()
case
.
useOriginal
:
case
.
noSnapshot
:
if
nil
==
superviewToNoSnapshotSubviewMap
[
view
.
superview
!
]
{
if
nil
==
superviewToNoSnapshotSubviewMap
[
view
.
superview
!
]
{
superviewToNoSnapshotSubviewMap
[
view
.
superview
!
]
=
[]
superviewToNoSnapshotSubviewMap
[
view
.
superview
!
]
=
[]
}
}
...
@@ -268,7 +268,7 @@ public extension MotionContext {
...
@@ -268,7 +268,7 @@ public extension MotionContext {
view
.
layer
.
cornerRadius
=
oldCornerRadius
view
.
layer
.
cornerRadius
=
oldCornerRadius
view
.
alpha
=
oldAlpha
view
.
alpha
=
oldAlpha
if
.
useOriginal
!=
snapshotType
{
if
.
noSnapshot
!=
snapshotType
{
snapshot
.
layer
.
allowsGroupOpacity
=
false
snapshot
.
layer
.
allowsGroupOpacity
=
false
if
!
(
view
is
UINavigationBar
),
let
contentView
=
snapshot
.
subviews
.
get
(
0
)
{
if
!
(
view
is
UINavigationBar
),
let
contentView
=
snapshot
.
subviews
.
get
(
0
)
{
...
@@ -362,7 +362,7 @@ internal extension MotionContext {
...
@@ -362,7 +362,7 @@ internal extension MotionContext {
- Parameter view: A UIView.
- Parameter view: A UIView.
*/
*/
func
hide
(
view
:
UIView
)
{
func
hide
(
view
:
UIView
)
{
guard
nil
==
viewToAlphas
[
view
],
.
useOriginal
!=
self
[
view
]?
.
snapshotType
else
{
guard
nil
==
viewToAlphas
[
view
],
.
noSnapshot
!=
self
[
view
]?
.
snapshotType
else
{
return
return
}
}
...
...
Sources/MotionSnapshotType.swift
View file @
a0a1e257
...
@@ -48,5 +48,5 @@ public enum MotionSnapshotType {
...
@@ -48,5 +48,5 @@ public enum MotionSnapshotType {
This will mess up the view hierarchy, therefore, view controllers have to rebuild
This will mess up the view hierarchy, therefore, view controllers have to rebuild
their view structure after the transition finishes.
their view structure after the transition finishes.
*/
*/
case
useOriginal
case
noSnapshot
}
}
Sources/MotionTransition.swift
View file @
a0a1e257
...
@@ -456,115 +456,113 @@ extension MotionTransition {
...
@@ -456,115 +456,113 @@ extension MotionTransition {
For destination views, they replace the target state (final appearance).
For destination views, they replace the target state (final appearance).
*/
*/
public
static
func
beginWith
(
transitions
:
[
MotionTransition
])
->
MotionTransition
{
public
static
func
beginWith
(
transitions
:
[
MotionTransition
])
->
MotionTransition
{
return
MotionTransition
{
targetState
in
return
MotionTransition
{
if
targetState
.
beginState
==
nil
{
if
$0
.
beginState
==
nil
{
targetState
.
beginState
=
MotionTransitionStateWrapper
(
state
:
[])
$0
.
beginState
=
MotionTransitionStateWrapper
(
state
:
[])
}
}
targetState
.
beginState
!.
state
.
append
(
contentsOf
:
transitions
)
$0
.
beginState
?
.
state
.
append
(
contentsOf
:
transitions
)
}
}
}
}
/**
/**
Apply transitions directly to the view at the start of the transition if the view is
matched with another view.
Apply transitions directly to the view at the start of the transition if the view is
The transitions supplied here won't be animated.
matched with another view.
The transitions supplied here won't be animated.
For source views, transitions are set directly at the begining of the animation.
For source views, transitions are set directly at the begining of the animation.
For destination views, they replace the target state (final appearance).
For destination views, they replace the target state (final appearance).
*/
*/
public
static
func
beginWithIfMatched
(
transitions
:
[
MotionTransition
])
->
MotionTransition
{
public
static
func
beginWithIfMatched
(
transitions
:
[
MotionTransition
])
->
MotionTransition
{
return
MotionTransition
{
targetState
in
return
MotionTransition
{
if
targetState
.
beginStateIfMatched
==
nil
{
if
$0
.
beginStateIfMatched
==
nil
{
targetState
.
beginStateIfMatched
=
[]
$0
.
beginStateIfMatched
=
[]
}
}
targetState
.
beginStateIfMatched
!.
append
(
contentsOf
:
transitions
)
$0
.
beginStateIfMatched
?
.
append
(
contentsOf
:
transitions
)
}
}
}
}
/**
/**
Use global coordinate space.
Use global coordinate space.
When using global coordinate space. The view become a independent view that is not a subview of any view.
When using global coordinate space. The view becomes an independent view that is not
It won't move when its parent view moves, and won't be affected by parent view's attributes.
a subview of any view. It won't move when its parent view moves, and won't be affected
by parent view attributes.
When a view is matched, this is automatically enabled.
When a view is matched, this is automatically enabled.
The `source` modifier will also enable this.
The `source` transition will also enable this.
Global coordinate space is default for all views prior to version 0.1.3
*/
*/
public
static
var
useGlobalCoordinateSpace
:
MotionTransition
=
MotionTransition
{
targetState
in
public
static
var
useGlobalCoordinateSpace
=
MotionTransition
{
targetState
.
coordinateSpace
=
.
global
$0
.
coordinateSpace
=
.
global
}
}
/**
/// Use same parent coordinate space.
Use same parent coordinate space.
public
static
var
useSameParentCoordinateSpace
=
MotionTransition
{
*/
$0
.
coordinateSpace
=
.
sameParent
public
static
var
useSameParentCoordinateSpace
:
MotionTransition
=
MotionTransition
{
targetState
in
targetState
.
coordinateSpace
=
.
sameParent
}
}
/**
/// Ignore all motion transition attributes for a view's direct subviews.
ignore all motionTransitions attributes for a view's direct subviews.
*/
public
static
var
ignoreSubviewTransitions
:
MotionTransition
=
.
ignoreSubviewTransitions
()
public
static
var
ignoreSubviewTransitions
:
MotionTransition
=
.
ignoreSubviewTransitions
()
/**
/**
ignore all motionTransitions
attributes for a view's subviews.
Ignore all motion transition
attributes for a view's subviews.
- Parameter
s:
- Parameter
recursive: If false, will only ignore direct subviews' transitions.
- recursive: if false, will only ignore direct subviews' transitions.
default false.
default false.
*/
*/
public
static
func
ignoreSubviewTransitions
(
recursive
:
Bool
=
false
)
->
MotionTransition
{
public
static
func
ignoreSubviewTransitions
(
recursive
:
Bool
=
false
)
->
MotionTransition
{
return
MotionTransition
{
targetState
in
return
MotionTransition
{
targetState
.
ignoreSubviewTransitions
=
recursive
$0
.
ignoreSubviewTransitions
=
recursive
}
}
}
}
/**
/**
Will create snapshot optimized for different view type
.
This will create a snapshot optimized for different view types
.
For custom views or views with masking, useOptimizedSnapshot might create snapshots
For custom views or views with masking, useOptimizedSnapshot might create snapshots
that appear differently than the actual view.
that appear differently than the actual view.
In that case, use .useNormalSnapshot or .useSlowRenderSnapshot to disable the optimization.
In that case, use .useNormalSnapshot or .useSlowRenderSnapshot to disable the optimization.
This modifier actually does nothing by itself since .useOptimizedSnapshot is the default.
This modifier actually does nothing by itself since .useOptimizedSnapshot is the default.
*/
*/
public
static
var
useOptimizedSnapshot
:
MotionTransition
=
MotionTransition
{
targetState
in
public
static
var
useOptimizedSnapshot
=
MotionTransition
{
targetState
.
snapshotType
=
.
optimized
$0
.
snapshotType
=
.
optimized
}
}
/**
/// Create a snapshot using snapshotView(afterScreenUpdates:).
Create snapshot using snapshotView(afterScreenUpdates:).
public
static
var
useNormalSnapshot
=
MotionTransition
{
*/
$0
.
snapshotType
=
.
normal
public
static
var
useNormalSnapshot
:
MotionTransition
=
MotionTransition
{
targetState
in
targetState
.
snapshotType
=
.
normal
}
}
/**
/**
Create snapshot using layer.render(in: currentContext).
Create a snapshot using layer.render(in: currentContext).
This is slower than .useNormalSnapshot but gives more accurate snapshot for some views (eg. UIStackView).
This is slower than .useNormalSnapshot but gives more accurate snapshots for some views
(eg. UIStackView).
*/
*/
public
static
var
useLayerRenderSnapshot
:
MotionTransition
=
MotionTransition
{
targetState
in
public
static
var
useLayerRenderSnapshot
=
MotionTransition
{
targetState
.
snapshotType
=
.
layerRender
$0
.
snapshotType
=
.
layerRender
}
}
/**
/**
Force Motion to not create any snapshot when animating this view.
Force Motion to not create any snapshot
s
when animating this view.
This will mess up the view hierarchy, therefore, view controllers have to rebuild
This will mess up the view hierarchy, therefore, view controllers have to rebuild
its
view structure after the transition finishes.
their
view structure after the transition finishes.
*/
*/
public
static
var
useNoSnapshot
:
MotionTransition
=
MotionTransition
{
targetState
in
public
static
var
useNoSnapshot
=
MotionTransition
{
targetState
.
snapshotType
=
.
useOriginal
$0
.
snapshotType
=
.
noSnapshot
}
}
/**
/**
Force the view to animate (Motion will create animation context & snapshots for them, so that they can be interact)
Force the view to animate (Motion will create animation contexts & snapshots for them, so
that they can be interactive).
*/
*/
public
static
var
forceAnimate
=
MotionTransition
{
targetState
in
public
static
var
forceAnimate
=
MotionTransition
{
targetState
.
forceAnimate
=
true
$0
.
forceAnimate
=
true
}
}
/**
/**
Force Motion use scale based size animation. This will convert all .size modifier into .scale modifier.
Force Motion to use scale based size animation. This will convert all .size transitions into
This is to help Motion animate layers that doesn't support bounds animation. Also gives better performance.
a .scale transition. This is to help Motion animate layers that doesn't support bounds animations.
This also gives better performance.
*/
*/
public
static
var
useScaleBasedSizeChange
:
MotionTransition
=
MotionTransition
{
targetState
in
public
static
var
useScaleBasedSizeChange
=
MotionTransition
{
targetState
.
useScaleBasedSizeChange
=
true
$0
.
useScaleBasedSizeChange
=
true
}
}
}
}
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