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
de05a397
Commit
de05a397
authored
Dec 12, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated MotionViewPropertyViewContext
parent
55e5e287
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
88 additions
and
103 deletions
+88
-103
Motion.xcodeproj/project.pbxproj
+0
-6
Sources/Animator/MotionHasInsertOrder.swift
+0
-32
Sources/Animator/MotionTransitionAnimator.swift
+33
-32
Sources/Animator/MotionViewPropertyViewContext.swift
+48
-15
Sources/Extensions/Motion+UIView.swift
+6
-5
Sources/Motion.swift
+0
-11
Sources/Preprocessors/DurationPreprocessor.swift
+1
-2
No files found.
Motion.xcodeproj/project.pbxproj
View file @
de05a397
...
@@ -18,7 +18,6 @@
...
@@ -18,7 +18,6 @@
96E409651F24F7370015A2B5
/* MotionAnimator.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4093D1F24F7370015A2B5
/* MotionAnimator.swift */
;
};
96E409651F24F7370015A2B5
/* MotionAnimator.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4093D1F24F7370015A2B5
/* MotionAnimator.swift */
;
};
96E409661F24F7370015A2B5
/* MotionAnimatorViewContext.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4093E1F24F7370015A2B5
/* MotionAnimatorViewContext.swift */
;
};
96E409661F24F7370015A2B5
/* MotionAnimatorViewContext.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4093E1F24F7370015A2B5
/* MotionAnimatorViewContext.swift */
;
};
96E409671F24F7370015A2B5
/* MotionCoreAnimationViewContext.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4093F1F24F7370015A2B5
/* MotionCoreAnimationViewContext.swift */
;
};
96E409671F24F7370015A2B5
/* MotionCoreAnimationViewContext.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4093F1F24F7370015A2B5
/* MotionCoreAnimationViewContext.swift */
;
};
96E409681F24F7370015A2B5
/* MotionHasInsertOrder.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409401F24F7370015A2B5
/* MotionHasInsertOrder.swift */
;
};
96E409691F24F7370015A2B5
/* MotionTransitionAnimator.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409411F24F7370015A2B5
/* MotionTransitionAnimator.swift */
;
};
96E409691F24F7370015A2B5
/* MotionTransitionAnimator.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409411F24F7370015A2B5
/* MotionTransitionAnimator.swift */
;
};
96E4096A1F24F7370015A2B5
/* MotionViewPropertyViewContext.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409421F24F7370015A2B5
/* MotionViewPropertyViewContext.swift */
;
};
96E4096A1F24F7370015A2B5
/* MotionViewPropertyViewContext.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409421F24F7370015A2B5
/* MotionViewPropertyViewContext.swift */
;
};
96E4096B1F24F7370015A2B5
/* Motion+Array.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409441F24F7370015A2B5
/* Motion+Array.swift */
;
};
96E4096B1F24F7370015A2B5
/* Motion+Array.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409441F24F7370015A2B5
/* Motion+Array.swift */
;
};
...
@@ -52,7 +51,6 @@
...
@@ -52,7 +51,6 @@
96E409891F24F7570015A2B5
/* MotionAnimator.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4093D1F24F7370015A2B5
/* MotionAnimator.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E409891F24F7570015A2B5
/* MotionAnimator.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4093D1F24F7370015A2B5
/* MotionAnimator.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E4098A1F24F7570015A2B5
/* MotionAnimatorViewContext.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4093E1F24F7370015A2B5
/* MotionAnimatorViewContext.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E4098A1F24F7570015A2B5
/* MotionAnimatorViewContext.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4093E1F24F7370015A2B5
/* MotionAnimatorViewContext.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E4098B1F24F7570015A2B5
/* MotionCoreAnimationViewContext.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4093F1F24F7370015A2B5
/* MotionCoreAnimationViewContext.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E4098B1F24F7570015A2B5
/* MotionCoreAnimationViewContext.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4093F1F24F7370015A2B5
/* MotionCoreAnimationViewContext.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E4098C1F24F7570015A2B5
/* MotionHasInsertOrder.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409401F24F7370015A2B5
/* MotionHasInsertOrder.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E4098D1F24F7570015A2B5
/* MotionTransitionAnimator.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409411F24F7370015A2B5
/* MotionTransitionAnimator.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E4098D1F24F7570015A2B5
/* MotionTransitionAnimator.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409411F24F7370015A2B5
/* MotionTransitionAnimator.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E4098E1F24F7570015A2B5
/* MotionViewPropertyViewContext.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409421F24F7370015A2B5
/* MotionViewPropertyViewContext.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E4098E1F24F7570015A2B5
/* MotionViewPropertyViewContext.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409421F24F7370015A2B5
/* MotionViewPropertyViewContext.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E4098F1F24F7570015A2B5
/* Motion+Array.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409441F24F7370015A2B5
/* Motion+Array.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E4098F1F24F7570015A2B5
/* Motion+Array.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409441F24F7370015A2B5
/* Motion+Array.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
...
@@ -97,7 +95,6 @@
...
@@ -97,7 +95,6 @@
96E4093D1F24F7370015A2B5
/* MotionAnimator.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionAnimator.swift
;
sourceTree
=
"<group>"
;
};
96E4093D1F24F7370015A2B5
/* MotionAnimator.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionAnimator.swift
;
sourceTree
=
"<group>"
;
};
96E4093E1F24F7370015A2B5
/* MotionAnimatorViewContext.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionAnimatorViewContext.swift
;
sourceTree
=
"<group>"
;
};
96E4093E1F24F7370015A2B5
/* MotionAnimatorViewContext.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionAnimatorViewContext.swift
;
sourceTree
=
"<group>"
;
};
96E4093F1F24F7370015A2B5
/* MotionCoreAnimationViewContext.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionCoreAnimationViewContext.swift
;
sourceTree
=
"<group>"
;
};
96E4093F1F24F7370015A2B5
/* MotionCoreAnimationViewContext.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionCoreAnimationViewContext.swift
;
sourceTree
=
"<group>"
;
};
96E409401F24F7370015A2B5
/* MotionHasInsertOrder.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionHasInsertOrder.swift
;
sourceTree
=
"<group>"
;
};
96E409411F24F7370015A2B5
/* MotionTransitionAnimator.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionTransitionAnimator.swift
;
sourceTree
=
"<group>"
;
};
96E409411F24F7370015A2B5
/* MotionTransitionAnimator.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionTransitionAnimator.swift
;
sourceTree
=
"<group>"
;
};
96E409421F24F7370015A2B5
/* MotionViewPropertyViewContext.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionViewPropertyViewContext.swift
;
sourceTree
=
"<group>"
;
};
96E409421F24F7370015A2B5
/* MotionViewPropertyViewContext.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionViewPropertyViewContext.swift
;
sourceTree
=
"<group>"
;
};
96E409441F24F7370015A2B5
/* Motion+Array.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Motion+Array.swift"
;
sourceTree
=
"<group>"
;
};
96E409441F24F7370015A2B5
/* Motion+Array.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Motion+Array.swift"
;
sourceTree
=
"<group>"
;
};
...
@@ -186,7 +183,6 @@
...
@@ -186,7 +183,6 @@
965FE96C1FDDA6400098BDD0
/* MotionCoreAnimator.swift */
,
965FE96C1FDDA6400098BDD0
/* MotionCoreAnimator.swift */
,
96E4093E1F24F7370015A2B5
/* MotionAnimatorViewContext.swift */
,
96E4093E1F24F7370015A2B5
/* MotionAnimatorViewContext.swift */
,
96E4093F1F24F7370015A2B5
/* MotionCoreAnimationViewContext.swift */
,
96E4093F1F24F7370015A2B5
/* MotionCoreAnimationViewContext.swift */
,
96E409401F24F7370015A2B5
/* MotionHasInsertOrder.swift */
,
96E409411F24F7370015A2B5
/* MotionTransitionAnimator.swift */
,
96E409411F24F7370015A2B5
/* MotionTransitionAnimator.swift */
,
96E409421F24F7370015A2B5
/* MotionViewPropertyViewContext.swift */
,
96E409421F24F7370015A2B5
/* MotionViewPropertyViewContext.swift */
,
);
);
...
@@ -234,7 +230,6 @@
...
@@ -234,7 +230,6 @@
96E409891F24F7570015A2B5
/* MotionAnimator.swift in Headers */
,
96E409891F24F7570015A2B5
/* MotionAnimator.swift in Headers */
,
96E4098A1F24F7570015A2B5
/* MotionAnimatorViewContext.swift in Headers */
,
96E4098A1F24F7570015A2B5
/* MotionAnimatorViewContext.swift in Headers */
,
96E4098B1F24F7570015A2B5
/* MotionCoreAnimationViewContext.swift in Headers */
,
96E4098B1F24F7570015A2B5
/* MotionCoreAnimationViewContext.swift in Headers */
,
96E4098C1F24F7570015A2B5
/* MotionHasInsertOrder.swift in Headers */
,
96E4098D1F24F7570015A2B5
/* MotionTransitionAnimator.swift in Headers */
,
96E4098D1F24F7570015A2B5
/* MotionTransitionAnimator.swift in Headers */
,
96E4098E1F24F7570015A2B5
/* MotionViewPropertyViewContext.swift in Headers */
,
96E4098E1F24F7570015A2B5
/* MotionViewPropertyViewContext.swift in Headers */
,
96E4098F1F24F7570015A2B5
/* Motion+Array.swift in Headers */
,
96E4098F1F24F7570015A2B5
/* Motion+Array.swift in Headers */
,
...
@@ -331,7 +326,6 @@
...
@@ -331,7 +326,6 @@
965FE96B1FDDA4EA0098BDD0
/* BaseMotionPreprocessor.swift in Sources */
,
965FE96B1FDDA4EA0098BDD0
/* BaseMotionPreprocessor.swift in Sources */
,
965FE9631FDCCE030098BDD0
/* Motion+Complete.swift in Sources */
,
965FE9631FDCCE030098BDD0
/* Motion+Complete.swift in Sources */
,
96E4097D1F24F7370015A2B5
/* MotionPlugin.swift in Sources */
,
96E4097D1F24F7370015A2B5
/* MotionPlugin.swift in Sources */
,
96E409681F24F7370015A2B5
/* MotionHasInsertOrder.swift in Sources */
,
965FE96D1FDDA6400098BDD0
/* MotionCoreAnimator.swift in Sources */
,
965FE96D1FDDA6400098BDD0
/* MotionCoreAnimator.swift in Sources */
,
96E4096E1F24F7370015A2B5
/* Motion+CG.swift in Sources */
,
96E4096E1F24F7370015A2B5
/* Motion+CG.swift in Sources */
,
96E409851F24F7370015A2B5
/* MatchPreprocessor.swift in Sources */
,
96E409851F24F7370015A2B5
/* MatchPreprocessor.swift in Sources */
,
...
...
Sources/Animator/MotionHasInsertOrder.swift
deleted
100644 → 0
View file @
55e5e287
/*
* The MIT License (MIT)
*
* Copyright (C) 2017, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>.
* All rights reserved.
*
* Original Inspiration & Author
* Copyright (c) 2016 Luke Zhao <me@lkzhao.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
internal
protocol
MotionHasInsertOrder
:
class
{
/// A boolean indicating whether to insert the toView first or not.
var
insertToViewFirst
:
Bool
{
get
set
}
}
Sources/Animator/MotionTransitionAnimator.swift
View file @
de05a397
...
@@ -28,12 +28,10 @@
...
@@ -28,12 +28,10 @@
import
UIKit
import
UIKit
internal
class
MotionTransitionAnimator
<
T
:
MotionAnimatorViewContext
>
:
MotionCoreAnimator
,
MotionHasInsertOrder
{
internal
class
MotionTransitionAnimator
<
T
:
MotionAnimatorViewContext
>
:
MotionCoreAnimator
{
/// An index of views to their corresponding animator context.
/// An index of views to their corresponding animator context.
var
viewToContexts
=
[
UIView
:
T
]()
var
viewToContexts
=
[
UIView
:
T
]()
var
insertToViewFirst
=
false
/// Cleans the contexts.
/// Cleans the contexts.
override
func
clean
()
{
override
func
clean
()
{
for
v
in
viewToContexts
.
values
{
for
v
in
viewToContexts
.
values
{
...
@@ -41,7 +39,6 @@ internal class MotionTransitionAnimator<T: MotionAnimatorViewContext>: MotionCor
...
@@ -41,7 +39,6 @@ internal class MotionTransitionAnimator<T: MotionAnimatorViewContext>: MotionCor
}
}
viewToContexts
.
removeAll
()
viewToContexts
.
removeAll
()
insertToViewFirst
=
false
}
}
/**
/**
...
@@ -65,32 +62,41 @@ internal class MotionTransitionAnimator<T: MotionAnimatorViewContext>: MotionCor
...
@@ -65,32 +62,41 @@ internal class MotionTransitionAnimator<T: MotionAnimatorViewContext>: MotionCor
- Returns: A TimeInterval.
- Returns: A TimeInterval.
*/
*/
override
func
animate
(
fromViews
:
[
UIView
],
toViews
:
[
UIView
])
->
TimeInterval
{
override
func
animate
(
fromViews
:
[
UIView
],
toViews
:
[
UIView
])
->
TimeInterval
{
var
d
uration
:
TimeInterval
=
0
var
d
:
TimeInterval
=
0
if
insertToViewFirst
{
for
v
in
fromViews
{
for
v
in
toViews
{
createViewContext
(
view
:
v
,
isAppearing
:
false
)
animate
(
view
:
v
,
isAppearing
:
true
)
}
}
for
v
in
toViews
{
for
v
in
fromViews
{
createViewContext
(
view
:
v
,
isAppearing
:
true
)
animate
(
view
:
v
,
isAppearing
:
false
)
}
}
for
v
in
viewToContexts
.
values
{
}
else
{
if
let
duration
=
v
.
targetState
.
duration
,
duration
!=
.
infinity
{
for
v
in
fromViews
{
v
.
duration
=
duration
animate
(
view
:
v
,
isAppearing
:
false
)
d
=
max
(
d
,
duration
)
}
for
v
in
toViews
{
}
else
{
animate
(
view
:
v
,
isAppearing
:
true
)
let
duration
=
v
.
snapshot
.
optimizedDuration
(
targetState
:
v
.
targetState
)
if
nil
==
v
.
targetState
.
duration
{
v
.
duration
=
duration
}
d
=
max
(
d
,
duration
)
}
}
}
}
for
v
in
viewToContexts
.
values
{
for
v
in
viewToContexts
.
values
{
duration
=
max
(
duration
,
v
.
duration
)
if
.
infinity
==
v
.
targetState
.
duration
{
v
.
duration
=
d
}
d
=
max
(
d
,
v
.
startAnimations
())
}
}
return
d
uration
return
d
}
}
/**
/**
...
@@ -114,7 +120,7 @@ internal class MotionTransitionAnimator<T: MotionAnimatorViewContext>: MotionCor
...
@@ -114,7 +120,7 @@ internal class MotionTransitionAnimator<T: MotionAnimatorViewContext>: MotionCor
var
duration
:
TimeInterval
=
0
var
duration
:
TimeInterval
=
0
for
(
_
,
v
)
in
viewToContexts
{
for
(
_
,
v
)
in
viewToContexts
{
if
v
.
targetState
.
duration
==
nil
{
if
nil
==
v
.
targetState
.
duration
{
v
.
duration
=
max
(
v
.
duration
,
v
.
snapshot
.
optimizedDuration
(
targetState
:
v
.
targetState
)
+
elapsedTime
)
v
.
duration
=
max
(
v
.
duration
,
v
.
snapshot
.
optimizedDuration
(
targetState
:
v
.
targetState
)
+
elapsedTime
)
}
}
duration
=
max
(
duration
,
v
.
resume
(
at
:
elapsedTime
,
isReversed
:
isReversed
))
duration
=
max
(
duration
,
v
.
resume
(
at
:
elapsedTime
,
isReversed
:
isReversed
))
...
@@ -137,20 +143,15 @@ internal class MotionTransitionAnimator<T: MotionAnimatorViewContext>: MotionCor
...
@@ -137,20 +143,15 @@ internal class MotionTransitionAnimator<T: MotionAnimatorViewContext>: MotionCor
}
}
}
}
extension
MotionTransitionAnimator
{
fileprivate
extension
MotionTransitionAnimator
{
/**
/**
Animates
a given view.
Creates a view context for
a given view.
- Parameter view: A UIView.
- Parameter view: A UIView.
- Parameter isAppearing: A boolean that determines whether the
- Parameter isAppearing: A boolean that determines whether the
view is appearing.
view is appearing.
*/
*/
fileprivate
func
animate
(
view
:
UIView
,
isAppearing
:
Bool
)
{
func
createViewContext
(
view
:
UIView
,
isAppearing
:
Bool
)
{
let
s
=
context
.
snapshotView
(
for
:
view
)
viewToContexts
[
view
]
=
T
(
animator
:
self
,
snapshot
:
context
.
snapshotView
(
for
:
view
),
targetState
:
context
[
view
]
!
,
isAppearing
:
isAppearing
)
let
v
=
T
(
animator
:
self
,
snapshot
:
s
,
targetState
:
context
[
view
]
!
,
isAppearing
:
isAppearing
)
viewToContexts
[
view
]
=
v
v
.
startAnimations
()
}
}
}
}
Sources/Animator/MotionViewPropertyViewContext.swift
View file @
de05a397
...
@@ -31,14 +31,38 @@ import UIKit
...
@@ -31,14 +31,38 @@ import UIKit
@available(iOS 10, tvOS 10, *)
@available(iOS 10, tvOS 10, *)
internal
class
MotionViewPropertyViewContext
:
MotionAnimatorViewContext
{
internal
class
MotionViewPropertyViewContext
:
MotionAnimatorViewContext
{
/// A reference to the UIViewPropertyAnimator.
/// A reference to the UIViewPropertyAnimator.
fileprivate
var
viewPropertyAnimator
:
UIViewPropertyAnimator
?
fileprivate
var
viewPropertyAnimator
:
UIViewPropertyAnimator
!
/// Ending effect.
fileprivate
var
endEffect
:
UIVisualEffect
?
/// Starting effect.
fileprivate
var
startEffect
:
UIVisualEffect
?
override
class
func
canAnimate
(
view
:
UIView
,
state
:
MotionTransitionState
,
isAppearing
:
Bool
)
->
Bool
{
override
class
func
canAnimate
(
view
:
UIView
,
state
:
MotionTransitionState
,
isAppearing
:
Bool
)
->
Bool
{
return
view
is
UIVisualEffectView
&&
nil
!=
state
.
opacity
return
view
is
UIVisualEffectView
&&
nil
!=
state
.
opacity
}
}
override
func
resume
(
at
elapsedTime
:
TimeInterval
,
isReversed
:
Bool
)
{
override
func
resume
(
at
elapsedTime
:
TimeInterval
,
isReversed
:
Bool
)
->
TimeInterval
{
viewPropertyAnimator
?
.
finishAnimation
(
at
:
isReversed
?
.
start
:
.
end
)
guard
let
visualEffectView
=
snapshot
as?
UIVisualEffectView
else
{
return
0
}
if
isReversed
{
viewPropertyAnimator
?
.
stopAnimation
(
false
)
viewPropertyAnimator
?
.
finishAnimation
(
at
:
.
current
)
viewPropertyAnimator
=
UIViewPropertyAnimator
(
duration
:
duration
,
curve
:
.
linear
)
{
[
weak
self
]
in
guard
let
`
self
`
=
self
else
{
return
}
visualEffectView
.
effect
=
isReversed
?
self
.
startEffect
:
self
.
endEffect
}
}
viewPropertyAnimator
.
startAnimation
()
return
duration
}
}
override
func
seek
(
to
elapsedTime
:
TimeInterval
)
{
override
func
seek
(
to
elapsedTime
:
TimeInterval
)
{
...
@@ -48,25 +72,34 @@ internal class MotionViewPropertyViewContext: MotionAnimatorViewContext {
...
@@ -48,25 +72,34 @@ internal class MotionViewPropertyViewContext: MotionAnimatorViewContext {
override
func
clean
()
{
override
func
clean
()
{
super
.
clean
()
super
.
clean
()
viewPropertyAnimator
?
.
stopAnimation
(
true
)
viewPropertyAnimator
?
.
stopAnimation
(
false
)
viewPropertyAnimator
?
.
finishAnimation
(
at
:
.
current
)
viewPropertyAnimator
=
nil
viewPropertyAnimator
=
nil
}
}
override
func
startAnimations
(
isAppearing
:
Bool
)
{
override
func
startAnimations
(
)
->
TimeInterval
{
guard
let
v
=
snapshot
as?
UIVisualEffectView
else
{
guard
let
v
isualEffectView
=
snapshot
as?
UIVisualEffectView
else
{
return
return
0
}
}
let
appearedEffect
=
v
.
effect
let
appearedEffect
=
v
isualEffectView
.
effect
let
disappearedEffect
=
0
==
targetState
.
opacity
?
nil
:
v
.
effect
let
disappearedEffect
=
targetState
.
opacity
==
0
?
nil
:
visualEffectView
.
effect
v
.
effect
=
isAppearing
?
disappearedEffect
:
appearedEffect
startEffect
=
isAppearing
?
disappearedEffect
:
appearedEffect
duration
=
targetState
.
duration
!
endEffect
=
isAppearing
?
appearedEffect
:
disappearedEffect
viewPropertyAnimator
=
UIViewPropertyAnimator
(
duration
:
duration
,
curve
:
.
easeInOut
)
{
visualEffectView
.
effect
=
startEffect
v
.
effect
=
isAppearing
?
appearedEffect
:
disappearedEffect
viewPropertyAnimator
=
UIViewPropertyAnimator
(
duration
:
duration
,
curve
:
.
linear
)
{
[
weak
self
]
in
guard
let
`
self
`
=
self
else
{
return
}
visualEffectView
.
effect
=
self
.
endEffect
}
}
viewPropertyAnimator
?
.
startAnimation
()
viewPropertyAnimator
.
startAnimation
()
return
duration
}
}
}
}
Sources/Extensions/Motion+UIView.swift
View file @
de05a397
...
@@ -264,22 +264,23 @@ internal extension UIView {
...
@@ -264,22 +264,23 @@ internal extension UIView {
- Parameter transform: An optional CATransform3D.
- Parameter transform: An optional CATransform3D.
- Returns: A TimeInterval.
- Returns: A TimeInterval.
*/
*/
func
optimizedDuration
(
fromPosition
:
CGPoint
,
toPosition
:
CGPoint
?,
size
:
CGSize
?,
transform
:
CATransform3D
?)
->
TimeInterval
{
func
optimizedDuration
(
position
:
CGPoint
?,
size
:
CGSize
?,
transform
:
CATransform3D
?)
->
TimeInterval
{
let
toPos
=
toPosition
??
fromPosition
let
fromPos
=
(
layer
.
presentation
()
??
layer
)
.
position
let
toPos
=
position
??
fromPos
let
fromSize
=
(
layer
.
presentation
()
??
layer
)
.
bounds
.
size
let
fromSize
=
(
layer
.
presentation
()
??
layer
)
.
bounds
.
size
let
toSize
=
size
??
fromSize
let
toSize
=
size
??
fromSize
let
fromTransform
=
(
layer
.
presentation
()
??
layer
)
.
transform
let
fromTransform
=
(
layer
.
presentation
()
??
layer
)
.
transform
let
toTransform
=
transform
??
fromTransform
let
toTransform
=
transform
??
fromTransform
let
realFromPos
=
CGPoint
.
zero
.
transform
(
fromTransform
)
+
fromPos
ition
let
realFromPos
=
CGPoint
.
zero
.
transform
(
fromTransform
)
+
fromPos
let
realToPos
=
CGPoint
.
zero
.
transform
(
toTransform
)
+
toPos
let
realToPos
=
CGPoint
.
zero
.
transform
(
toTransform
)
+
toPos
let
realFromSize
=
fromSize
.
transform
(
fromTransform
)
let
realFromSize
=
fromSize
.
transform
(
fromTransform
)
let
realToSize
=
toSize
.
transform
(
toTransform
)
let
realToSize
=
toSize
.
transform
(
toTransform
)
let
movePoints
=
realFromPos
.
distance
(
realToPos
)
+
realFromSize
.
bottomRight
.
distance
(
realToSize
.
bottomRight
)
let
movePoints
=
(
realFromPos
.
distance
(
realToPos
)
+
realFromSize
.
bottomRight
.
distance
(
realToSize
.
bottomRight
)
)
//
D
uration is 0.2 @ 0 to 0.375 @ 500
//
d
uration is 0.2 @ 0 to 0.375 @ 500
return
0.208
+
Double
(
movePoints
.
clamp
(
0
,
500
))
/
3000
return
0.208
+
Double
(
movePoints
.
clamp
(
0
,
500
))
/
3000
}
}
...
...
Sources/Motion.swift
View file @
de05a397
...
@@ -459,17 +459,6 @@ internal extension Motion {
...
@@ -459,17 +459,6 @@ internal extension Motion {
container
?
.
backgroundColor
=
toView
?
.
backgroundColor
container
?
.
backgroundColor
=
toView
?
.
backgroundColor
}
}
}
}
/// Updates the insertToViewFirst boolean for animators.
func
updateInsertOrder
()
{
if
fromOverFullScreen
{
context
.
insertToViewFirst
=
true
}
for
v
in
animators
{
(
v
as?
MotionHasInsertOrder
)?
.
insertToViewFirst
=
context
.
insertToViewFirst
}
}
}
}
internal
extension
Motion
{
internal
extension
Motion
{
...
...
Sources/Preprocessors/DurationPreprocessor.swift
View file @
de05a397
...
@@ -50,8 +50,7 @@ class DurationPreprocessor: BaseMotionPreprocessor {
...
@@ -50,8 +50,7 @@ class DurationPreprocessor: BaseMotionPreprocessor {
func
optimizedDuration
(
for
view
:
UIView
)
->
TimeInterval
{
func
optimizedDuration
(
for
view
:
UIView
)
->
TimeInterval
{
let
v
=
context
[
view
]
!
let
v
=
context
[
view
]
!
return
view
.
optimizedDuration
(
fromPosition
:
context
.
container
.
convert
(
view
.
layer
.
position
,
from
:
view
.
superview
),
return
view
.
optimizedDuration
(
position
:
context
.
container
.
convert
(
view
.
layer
.
position
,
from
:
view
.
superview
),
toPosition
:
v
.
position
,
size
:
v
.
size
,
size
:
v
.
size
,
transform
:
v
.
transform
)
transform
:
v
.
transform
)
}
}
...
...
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