Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
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
Material
Commits
f11fd48d
Unverified
Commit
f11fd48d
authored
Jan 18, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: updated animations when transitioning presentation views
parent
ee27036f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
115 deletions
+32
-115
Sources/iOS/MotionAnimation.swift
+2
-110
Sources/iOS/MotionTransition.swift
+30
-5
No files found.
Sources/iOS/MotionAnimation.swift
View file @
f11fd48d
...
@@ -290,119 +290,11 @@ extension UIView {
...
@@ -290,119 +290,11 @@ extension UIView {
}
}
open
func
motion
(
_
animations
:
MotionAnimation
...
)
{
open
func
motion
(
_
animations
:
MotionAnimation
...
)
{
motion
(
animations
)
layer
.
motion
(
animations
)
}
}
open
func
motion
(
_
animations
:
[
MotionAnimation
])
{
open
func
motion
(
_
animations
:
[
MotionAnimation
])
{
motion
(
delay
:
0
,
duration
:
0.25
,
timingFunction
:
.
easeInEaseOut
,
animations
:
animations
)
layer
.
motion
(
animations
)
}
fileprivate
func
motion
(
delay
:
TimeInterval
,
duration
:
TimeInterval
,
timingFunction
:
MotionAnimationTimingFunction
,
animations
:
[
MotionAnimation
])
{
var
t
=
delay
var
w
:
CGFloat
=
0
var
h
:
CGFloat
=
0
for
v
in
animations
{
switch
v
{
case
let
.
delay
(
time
):
t
=
time
case
let
.
width
(
width
):
w
=
width
case
let
.
height
(
height
):
h
=
height
default
:
break
}
}
Motion
.
delay
(
t
)
{
[
weak
self
]
in
guard
let
s
=
self
else
{
return
}
var
a
=
[
CABasicAnimation
]()
var
tf
=
timingFunction
var
d
=
duration
for
v
in
animations
{
switch
v
{
case
let
.
timingFunction
(
timingFunction
):
tf
=
timingFunction
case
let
.
duration
(
duration
):
d
=
duration
case
let
.
custom
(
animation
):
a
.
append
(
animation
)
case
let
.
backgroundColor
(
color
):
a
.
append
(
Motion
.
background
(
color
:
color
))
case
let
.
corners
(
radius
):
a
.
append
(
Motion
.
corner
(
radius
:
radius
))
case
let
.
transform
(
transform
):
a
.
append
(
Motion
.
transform
(
transform
:
transform
))
case
let
.
rotate
(
angle
):
let
rotate
=
Motion
.
rotate
(
angle
:
angle
)
let
radians
=
CGFloat
(
atan2f
(
Float
(
s
.
transform
.
b
),
Float
(
s
.
transform
.
a
)))
rotate
.
fromValue
=
(
radians
*
(
180
/
CGFloat
(
M_PI
)))
as
NSNumber
a
.
append
(
rotate
)
case
let
.
rotateX
(
angle
):
a
.
append
(
Motion
.
rotateX
(
angle
:
angle
))
case
let
.
rotateY
(
angle
):
a
.
append
(
Motion
.
rotateY
(
angle
:
angle
))
case
let
.
rotateZ
(
angle
):
a
.
append
(
Motion
.
rotateZ
(
angle
:
angle
))
case
let
.
spin
(
rotations
):
a
.
append
(
Motion
.
spin
(
rotations
:
rotations
))
case
let
.
spinX
(
rotations
):
a
.
append
(
Motion
.
spinX
(
rotations
:
rotations
))
case
let
.
spinY
(
rotations
):
a
.
append
(
Motion
.
spinY
(
rotations
:
rotations
))
case
let
.
spinZ
(
rotations
):
a
.
append
(
Motion
.
spinZ
(
rotations
:
rotations
))
case
let
.
scale
(
to
):
a
.
append
(
Motion
.
scale
(
to
:
to
))
case
let
.
scaleX
(
to
):
a
.
append
(
Motion
.
scaleX
(
to
:
to
))
case
let
.
scaleY
(
to
):
a
.
append
(
Motion
.
scaleY
(
to
:
to
))
case
let
.
scaleZ
(
to
):
a
.
append
(
Motion
.
scaleZ
(
to
:
to
))
case
let
.
translate
(
x
,
y
):
a
.
append
(
Motion
.
translate
(
to
:
CGPoint
(
x
:
x
,
y
:
y
)))
case
let
.
translateX
(
to
):
a
.
append
(
Motion
.
translateX
(
to
:
to
))
case
let
.
translateY
(
to
):
a
.
append
(
Motion
.
translateY
(
to
:
to
))
case
let
.
translateZ
(
to
):
a
.
append
(
Motion
.
translateZ
(
to
:
to
))
case
let
.
x
(
x
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
x
+
w
/
2
,
y
:
s
.
position
.
y
)))
case
let
.
y
(
y
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
s
.
position
.
x
,
y
:
y
+
h
/
2
)))
case
let
.
position
(
x
,
y
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
x
,
y
:
y
)))
case
let
.
shadow
(
path
):
a
.
append
(
Motion
.
shadow
(
path
:
path
))
case
let
.
fade
(
opacity
):
let
fade
=
Motion
.
fade
(
opacity
:
opacity
)
fade
.
fromValue
=
s
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
opacity
.
rawValue
)
??
NSNumber
(
floatLiteral
:
1
)
a
.
append
(
fade
)
case
let
.
zPosition
(
index
):
let
zPosition
=
Motion
.
zPosition
(
index
:
index
)
zPosition
.
fromValue
=
s
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
zPosition
.
rawValue
)
??
NSNumber
(
integerLiteral
:
0
)
a
.
append
(
zPosition
)
case
let
.
width
(
w
):
a
.
append
(
Motion
.
width
(
w
))
case
let
.
height
(
h
):
a
.
append
(
Motion
.
height
(
h
))
default
:
break
}
}
let
g
=
Motion
.
animate
(
group
:
a
,
duration
:
d
)
g
.
fillMode
=
MotionAnimationFillModeToValue
(
mode
:
.
forwards
)
g
.
isRemovedOnCompletion
=
false
g
.
timingFunction
=
MotionAnimationTimingFunctionToValue
(
timingFunction
:
tf
)
s
.
animate
(
g
)
}
}
}
}
}
...
...
Sources/iOS/MotionTransition.swift
View file @
f11fd48d
...
@@ -432,6 +432,11 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
...
@@ -432,6 +432,11 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
var
a
=
[
CABasicAnimation
]()
var
a
=
[
CABasicAnimation
]()
var
tf
=
MotionAnimationTimingFunction
.
easeInEaseOut
var
tf
=
MotionAnimationTimingFunction
.
easeInEaseOut
var
w
:
CGFloat
=
0
var
h
:
CGFloat
=
0
var
px
:
CGFloat
=
v
.
position
.
x
var
py
:
CGFloat
=
v
.
position
.
y
for
ta
in
v
.
transitionAnimations
{
for
ta
in
v
.
transitionAnimations
{
switch
ta
{
switch
ta
{
case
let
.
delay
(
time
):
case
let
.
delay
(
time
):
...
@@ -443,6 +448,27 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
...
@@ -443,6 +448,27 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
if
time
>
duration
{
if
time
>
duration
{
duration
=
time
duration
=
time
}
}
case
let
.
width
(
width
):
w
=
width
case
let
.
height
(
height
):
h
=
height
default
:
break
}
}
for
ta
in
v
.
transitionAnimations
{
switch
ta
{
case
let
.
x
(
x
):
px
=
x
+
w
/
2
case
let
.
y
(
y
):
py
=
y
+
h
/
2
default
:
break
}
}
Motion
.
delay
(
d
)
{
for
ta
in
v
.
transitionAnimations
{
switch
ta
{
case
let
.
timingFunction
(
timingFunction
):
case
let
.
timingFunction
(
timingFunction
):
tf
=
timingFunction
tf
=
timingFunction
case
let
.
rotate
(
angle
):
case
let
.
rotate
(
angle
):
...
@@ -455,9 +481,9 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
...
@@ -455,9 +481,9 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
case
let
.
corners
(
radius
):
case
let
.
corners
(
radius
):
a
.
append
(
Motion
.
corner
(
radius
:
radius
))
a
.
append
(
Motion
.
corner
(
radius
:
radius
))
case
let
.
x
(
x
):
case
let
.
x
(
x
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
x
+
v
.
bounds
.
width
/
2
,
y
:
v
.
position
.
y
)))
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
x
+
w
/
2
,
y
:
p
y
)))
case
let
.
y
(
y
):
case
let
.
y
(
y
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
v
.
position
.
x
,
y
:
y
+
v
.
bounds
.
height
/
2
)))
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
px
,
y
:
y
+
h
/
2
)))
case
let
.
position
(
x
,
y
):
case
let
.
position
(
x
,
y
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
x
,
y
:
y
)))
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
x
,
y
:
y
)))
case
let
.
shadow
(
path
):
case
let
.
shadow
(
path
):
...
@@ -470,7 +496,6 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
...
@@ -470,7 +496,6 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
}
}
}
}
Motion
.
delay
(
d
)
{
let
g
=
Motion
.
animate
(
group
:
a
,
duration
:
duration
)
let
g
=
Motion
.
animate
(
group
:
a
,
duration
:
duration
)
g
.
fillMode
=
MotionAnimationFillModeToValue
(
mode
:
.
forwards
)
g
.
fillMode
=
MotionAnimationFillModeToValue
(
mode
:
.
forwards
)
g
.
isRemovedOnCompletion
=
false
g
.
isRemovedOnCompletion
=
false
...
@@ -557,9 +582,9 @@ open class MotionTransitionDismissedAnimator: MotionTransitionDelegate, UIViewCo
...
@@ -557,9 +582,9 @@ open class MotionTransitionDismissedAnimator: MotionTransitionDelegate, UIViewCo
case
let
.
corners
(
radius
):
case
let
.
corners
(
radius
):
a
.
append
(
Motion
.
corner
(
radius
:
v2
.
cornerRadius
))
a
.
append
(
Motion
.
corner
(
radius
:
v2
.
cornerRadius
))
case
let
.
x
(
x
):
case
let
.
x
(
x
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
v2
.
x
+
v2
.
bounds
.
width
/
2
,
y
:
v2
.
position
.
y
)
))
a
.
append
(
Motion
.
position
(
to
:
v2
.
position
))
case
let
.
y
(
y
):
case
let
.
y
(
y
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
v2
.
position
.
x
,
y
:
v2
.
y
+
v2
.
bounds
.
height
/
2
)
))
a
.
append
(
Motion
.
position
(
to
:
v2
.
position
))
case
let
.
position
(
x
,
y
):
case
let
.
position
(
x
,
y
):
a
.
append
(
Motion
.
position
(
to
:
v2
.
position
))
a
.
append
(
Motion
.
position
(
to
:
v2
.
position
))
case
let
.
shadow
(
path
):
case
let
.
shadow
(
path
):
...
...
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