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
469f4cfc
Unverified
Commit
469f4cfc
authored
Jan 09, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: added MotionAnimation enum type and helper methods to CALayer and UIView as extensions
parent
62b4f4ac
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
71 deletions
+4
-71
Sources/iOS/BasicMotion.swift
+0
-0
Sources/iOS/Material+CALayer.swift
+1
-59
Sources/iOS/Material+UIView.swift
+0
-9
Sources/iOS/PulseMotion.swift
+3
-3
No files found.
Sources/iOS/BasicMotion.swift
View file @
469f4cfc
This diff is collapsed.
Click to expand it.
Sources/iOS/Material+CALayer.swift
View file @
469f4cfc
...
...
@@ -248,61 +248,6 @@ extension CALayer {
}
}
/**
A method that accepts CAAnimation objects and executes them on the
view's backing layer.
- Parameter animation: A CAAnimation instance.
*/
open
func
animate
(
animation
:
CAAnimation
)
{
animation
.
delegate
=
self
if
let
a
=
animation
as?
CABasicAnimation
{
a
.
fromValue
=
(
presentation
()
??
self
)
.
value
(
forKeyPath
:
a
.
keyPath
!
)
}
if
let
a
=
animation
as?
CAPropertyAnimation
{
add
(
a
,
forKey
:
a
.
keyPath
!
)
}
else
if
let
a
=
animation
as?
CAAnimationGroup
{
add
(
a
,
forKey
:
nil
)
}
else
if
let
a
=
animation
as?
CATransition
{
add
(
a
,
forKey
:
kCATransition
)
}
}
/**
A delegation method that is executed when the backing layer stops
running an animation.
- Parameter animation: The CAAnimation instance that stopped running.
- Parameter flag: A boolean that indicates if the animation stopped
because it was completed or interrupted. True if completed, false
if interrupted.
*/
open
func
animationDidStop
(
_
animation
:
CAAnimation
,
finished
flag
:
Bool
)
{
guard
let
a
=
animation
as?
CAPropertyAnimation
else
{
if
let
a
=
(
animation
as?
CAAnimationGroup
)?
.
animations
{
for
x
in
a
{
animationDidStop
(
x
,
finished
:
true
)
}
}
return
}
guard
let
b
=
a
as?
CABasicAnimation
else
{
return
}
guard
let
v
=
b
.
toValue
else
{
return
}
guard
let
k
=
b
.
keyPath
else
{
return
}
setValue
(
v
,
forKeyPath
:
k
)
removeAnimation
(
forKey
:
k
)
}
/// Manages the layout for the shape of the view instance.
open
func
layoutShape
()
{
guard
.
none
!=
shapePreset
else
{
...
...
@@ -335,12 +280,9 @@ extension CALayer {
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
}
else
{
let
a
=
Motion
.
shadow
Path
(
to
:
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
)
let
a
=
Motion
.
shadow
(
path
:
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
)
a
.
fromValue
=
shadowPath
animate
(
animation
:
a
)
}
}
}
@available(iOS 10, *)
extension
CALayer
:
CAAnimationDelegate
{}
Sources/iOS/Material+UIView.swift
View file @
469f4cfc
...
...
@@ -268,15 +268,6 @@ extension UIView {
}
}
/**
A method that accepts CAAnimation objects and executes them on the
view's backing layer.
- Parameter animation: A CAAnimation instance.
*/
open
func
animate
(
animation
:
CAAnimation
)
{
layer
.
animate
(
animation
:
animation
)
}
/// Manages the layout for the shape of the view instance.
open
func
layoutShape
()
{
layer
.
layoutShape
()
...
...
Sources/iOS/PulseMotion.swift
View file @
469f4cfc
...
...
@@ -146,7 +146,7 @@ extension PulseMotion {
switch
animation
{
case
.
centerWithBacking
,
.
backing
,
.
pointWithBacking
,
.
tap
:
bLayer
.
add
(
Motion
.
background
Color
(
color
:
color
.
withAlphaComponent
(
opacity
/
2
),
duration
:
duration
),
forKey
:
nil
)
bLayer
.
add
(
Motion
.
background
(
color
:
color
.
withAlphaComponent
(
opacity
/
2
),
duration
:
duration
),
forKey
:
nil
)
default
:
break
}
...
...
@@ -182,7 +182,7 @@ extension PulseMotion {
switch
animation
{
case
.
centerWithBacking
,
.
backing
,
.
pointWithBacking
,
.
tap
:
bLayer
.
add
(
Motion
.
background
Color
(
color
:
color
.
withAlphaComponent
(
0
),
duration
:
duration
),
forKey
:
nil
)
bLayer
.
add
(
Motion
.
background
(
color
:
color
.
withAlphaComponent
(
0
),
duration
:
duration
),
forKey
:
nil
)
default
:
break
}
...
...
@@ -190,7 +190,7 @@ extension PulseMotion {
case
.
center
,
.
centerWithBacking
,
.
centerRadialBeyondBounds
,
.
radialBeyondBounds
,
.
point
,
.
pointWithBacking
:
pLayer
.
add
(
Motion
.
animate
(
group
:
[
Motion
.
scale
(
by
:
.
center
==
animation
?
1
:
1.325
),
Motion
.
background
Color
(
color
:
color
.
withAlphaComponent
(
0
))
Motion
.
background
(
color
:
color
.
withAlphaComponent
(
0
))
],
duration
:
duration
),
forKey
:
nil
)
default
:
break
}
...
...
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