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
dc6c0098
Commit
dc6c0098
authored
Oct 02, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated animations with MaterialAnimation
parent
3ddfac11
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
27 deletions
+47
-27
Source/MaterialAnimation.swift
+2
-14
Source/MaterialBasicAnimation.swift
+45
-13
No files found.
Source/MaterialAnimation.swift
View file @
dc6c0098
...
@@ -33,7 +33,7 @@ public struct MaterialAnimation {
...
@@ -33,7 +33,7 @@ public struct MaterialAnimation {
:name: groupAnimation
:name: groupAnimation
*/
*/
public
static
func
groupAnimation
(
view
:
UIView
,
animations
:
Array
<
CAAnimation
>
,
duration
:
NSTimeInterval
=
0.5
)
{
public
static
func
groupAnimation
(
view
:
UIView
,
animations
:
Array
<
CAAnimation
>
,
duration
:
NSTimeInterval
=
0.5
)
{
return
groupAnimation
(
view
.
layer
,
animations
:
animations
,
duration
:
duration
)
groupAnimation
(
view
.
layer
,
animations
:
animations
,
duration
:
duration
)
}
}
/**
/**
...
@@ -50,15 +50,7 @@ public struct MaterialAnimation {
...
@@ -50,15 +50,7 @@ public struct MaterialAnimation {
:name: applyBasicAnimation
:name: applyBasicAnimation
*/
*/
internal
static
func
applyBasicAnimation
(
animation
:
CABasicAnimation
,
toLayer
layer
:
CALayer
,
completion
:
(()
->
Void
)?
=
nil
)
{
internal
static
func
applyBasicAnimation
(
animation
:
CABasicAnimation
,
toLayer
layer
:
CALayer
,
completion
:
(()
->
Void
)?
=
nil
)
{
// use presentation layer if available
groupAnimation
(
layer
,
animations
:
[
animation
],
duration
:
animation
.
duration
)
animation
.
fromValue
=
(
nil
==
layer
.
presentationLayer
()
?
layer
:
layer
.
presentationLayer
()
as!
CALayer
)
.
valueForKeyPath
(
animation
.
keyPath
!
)
CATransaction
.
begin
()
CATransaction
.
setDisableActions
(
true
)
CATransaction
.
setCompletionBlock
(
completion
)
layer
.
setValue
(
nil
==
animation
.
toValue
?
animation
.
byValue
:
animation
.
toValue
,
forKey
:
animation
.
keyPath
!
)
CATransaction
.
commit
()
layer
.
addAnimation
(
animation
,
forKey
:
animation
.
keyPath
!
)
animation
.
delegate
=
self
as?
AnyObject
}
}
/**
/**
...
@@ -68,8 +60,4 @@ public struct MaterialAnimation {
...
@@ -68,8 +60,4 @@ public struct MaterialAnimation {
// use presentation layer if available
// use presentation layer if available
(
nil
==
layer
.
presentationLayer
()
?
layer
:
layer
.
presentationLayer
()
as!
CALayer
)
.
addAnimation
(
animation
,
forKey
:
animation
.
keyPath
!
)
(
nil
==
layer
.
presentationLayer
()
?
layer
:
layer
.
presentationLayer
()
as!
CALayer
)
.
addAnimation
(
animation
,
forKey
:
animation
.
keyPath
!
)
}
}
internal
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
print
(
"HERE"
)
}
}
}
Source/MaterialBasicAnimation.swift
View file @
dc6c0098
...
@@ -32,17 +32,18 @@ public extension MaterialAnimation {
...
@@ -32,17 +32,18 @@ public extension MaterialAnimation {
/**
/**
:name: backgroundColor
:name: backgroundColor
*/
*/
public
static
func
backgroundColor
(
view
:
UIView
,
color
:
UIColor
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
public
static
func
backgroundColor
(
view
:
UIView
,
color
:
UIColor
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
backgroundColor
(
view
.
layer
,
color
:
color
,
duration
:
duration
,
completion
:
completion
)
return
backgroundColor
(
view
.
layer
,
color
:
color
,
duration
:
duration
,
completion
:
completion
)
}
}
/**
/**
:name: backgroundColor
:name: backgroundColor
*/
*/
public
static
func
backgroundColor
(
layer
:
CALayer
,
color
:
UIColor
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
public
static
func
backgroundColor
(
layer
:
CALayer
,
color
:
UIColor
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
backgroundColorAnimation
(
color
)
let
animation
:
CABasicAnimation
=
backgroundColorAnimation
(
color
)
animation
.
duration
=
duration
animation
.
duration
=
duration
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
return
animation
}
}
/**
/**
...
@@ -58,17 +59,18 @@ public extension MaterialAnimation {
...
@@ -58,17 +59,18 @@ public extension MaterialAnimation {
/**
/**
:name: cornerRadius
:name: cornerRadius
*/
*/
public
static
func
cornerRadius
(
view
:
UIView
,
radius
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
public
static
func
cornerRadius
(
view
:
UIView
,
radius
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
cornerRadius
(
view
.
layer
,
radius
:
radius
,
duration
:
duration
,
completion
:
completion
)
return
cornerRadius
(
view
.
layer
,
radius
:
radius
,
duration
:
duration
,
completion
:
completion
)
}
}
/**
/**
:name: cornerRadius
:name: cornerRadius
*/
*/
public
static
func
cornerRadius
(
layer
:
CALayer
,
radius
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
public
static
func
cornerRadius
(
layer
:
CALayer
,
radius
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
cornerRadiusAnimation
(
radius
)
let
animation
:
CABasicAnimation
=
cornerRadiusAnimation
(
radius
)
animation
.
duration
=
duration
animation
.
duration
=
duration
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
return
animation
}
}
/**
/**
...
@@ -84,17 +86,18 @@ public extension MaterialAnimation {
...
@@ -84,17 +86,18 @@ public extension MaterialAnimation {
/**
/**
:name: rotation
:name: rotation
*/
*/
public
static
func
rotation
(
view
:
UIView
,
rotations
:
Int
=
1
,
duration
:
CFTimeInterval
=
0.5
,
completion
:
(()
->
Void
)?
=
nil
)
{
public
static
func
rotation
(
view
:
UIView
,
rotations
:
Int
=
1
,
duration
:
CFTimeInterval
=
0.5
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
rotation
(
view
.
layer
,
rotations
:
rotations
,
duration
:
duration
,
completion
:
completion
)
r
eturn
r
otation
(
view
.
layer
,
rotations
:
rotations
,
duration
:
duration
,
completion
:
completion
)
}
}
/**
/**
:name: rotation
:name: rotation
*/
*/
public
static
func
rotation
(
layer
:
CALayer
,
rotations
:
Int
=
1
,
duration
:
CFTimeInterval
=
0.5
,
completion
:
(()
->
Void
)?
=
nil
)
{
public
static
func
rotation
(
layer
:
CALayer
,
rotations
:
Int
=
1
,
duration
:
CFTimeInterval
=
0.5
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
rotationAnimation
(
rotations
)
let
animation
:
CABasicAnimation
=
rotationAnimation
(
rotations
)
animation
.
duration
=
duration
animation
.
duration
=
duration
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
return
animation
}
}
/**
/**
...
@@ -102,7 +105,7 @@ public extension MaterialAnimation {
...
@@ -102,7 +105,7 @@ public extension MaterialAnimation {
*/
*/
public
static
func
scaleAnimation
(
transform
:
CATransform3D
)
->
CABasicAnimation
{
public
static
func
scaleAnimation
(
transform
:
CATransform3D
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
()
let
animation
:
CABasicAnimation
=
CABasicAnimation
()
animation
.
keyPath
=
"transform
.scale
"
animation
.
keyPath
=
"transform"
animation
.
toValue
=
NSValue
(
CATransform3D
:
transform
)
animation
.
toValue
=
NSValue
(
CATransform3D
:
transform
)
return
animation
return
animation
}
}
...
@@ -110,16 +113,44 @@ public extension MaterialAnimation {
...
@@ -110,16 +113,44 @@ public extension MaterialAnimation {
/**
/**
:name: scale
:name: scale
*/
*/
public
static
func
scale
(
view
:
UIView
,
transform
:
CATransform3D
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
public
static
func
scale
(
view
:
UIView
,
transform
:
CATransform3D
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
scale
(
view
.
layer
,
transform
:
transform
,
duration
:
duration
,
completion
:
completion
)
return
scale
(
view
.
layer
,
transform
:
transform
,
duration
:
duration
,
completion
:
completion
)
}
}
/**
/**
:name: scale
:name: scale
*/
*/
public
static
func
scale
(
layer
:
CALayer
,
transform
:
CATransform3D
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
public
static
func
scale
(
layer
:
CALayer
,
transform
:
CATransform3D
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
scaleAnimation
(
transform
)
let
animation
:
CABasicAnimation
=
scaleAnimation
(
transform
)
animation
.
duration
=
duration
animation
.
duration
=
duration
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
return
animation
}
/**
:name: positionAnimation
*/
public
static
func
positionAnimation
(
point
:
CGPoint
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
()
animation
.
keyPath
=
"position"
animation
.
toValue
=
NSValue
(
CGPoint
:
point
)
return
animation
}
/**
:name: position
*/
public
static
func
position
(
view
:
UIView
,
point
:
CGPoint
,
duration
:
CFTimeInterval
=
0.5
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
return
position
(
view
.
layer
,
point
:
point
,
duration
:
duration
,
completion
:
completion
)
}
/**
:name: position
*/
public
static
func
position
(
layer
:
CALayer
,
point
:
CGPoint
,
duration
:
CFTimeInterval
=
0.5
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
positionAnimation
(
point
)
animation
.
duration
=
duration
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
return
animation
}
}
}
}
\ No newline at end of file
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