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
3ddfac11
Commit
3ddfac11
authored
Oct 02, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated Animation components and included scale
parent
a202a838
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
54 deletions
+79
-54
Source/MaterialAnimation.swift
+8
-8
Source/MaterialBasicAnimation.swift
+29
-29
Source/MaterialButton.swift
+17
-4
Source/MaterialKeyframeAnimation.swift
+9
-9
Source/MaterialPulseView.swift
+4
-4
Source/MaterialView.swift
+12
-0
No files found.
Source/MaterialAnimation.swift
View file @
3ddfac11
...
...
@@ -55,13 +55,10 @@ public struct MaterialAnimation {
CATransaction
.
begin
()
CATransaction
.
setDisableActions
(
true
)
CATransaction
.
setCompletionBlock
(
completion
)
if
let
v
=
animation
.
toValue
{
layer
.
setValue
(
v
,
forKey
:
animation
.
keyPath
!
)
}
else
if
let
v
=
animation
.
byValue
{
layer
.
setValue
(
v
,
forKey
:
animation
.
keyPath
!
)
}
layer
.
setValue
(
nil
==
animation
.
toValue
?
animation
.
byValue
:
animation
.
toValue
,
forKey
:
animation
.
keyPath
!
)
CATransaction
.
commit
()
layer
.
addAnimation
(
animation
,
forKey
:
nil
)
layer
.
addAnimation
(
animation
,
forKey
:
animation
.
keyPath
!
)
animation
.
delegate
=
self
as?
AnyObject
}
/**
...
...
@@ -69,7 +66,10 @@ public struct MaterialAnimation {
*/
internal
static
func
applyKeyframeAnimation
(
animation
:
CAKeyframeAnimation
,
toLayer
layer
:
CALayer
)
{
// use presentation layer if available
(
nil
==
layer
.
presentationLayer
()
?
layer
:
layer
.
presentationLayer
()
as!
CALayer
)
.
addAnimation
(
animation
,
forKey
:
nil
)
(
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 @
3ddfac11
...
...
@@ -46,79 +46,79 @@ public extension MaterialAnimation {
}
/**
:name:
rotation
Animation
:name:
cornerRadius
Animation
*/
public
static
func
rotationAnimation
(
rotations
:
Int
=
1
)
->
CABasicAnimation
{
public
static
func
cornerRadiusAnimation
(
radius
:
CGFloat
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
()
animation
.
keyPath
=
"
transform.rotation
"
animation
.
byValue
=
M_PI
*
2
*
Double
(
rotations
)
animation
.
keyPath
=
"
cornerRadius
"
animation
.
toValue
=
radius
return
animation
}
/**
:name:
rotation
:name:
cornerRadius
*/
public
static
func
rotation
(
view
:
UIView
,
rotations
:
Int
=
1
,
duration
:
CFTimeInterval
=
0.
5
,
completion
:
(()
->
Void
)?
=
nil
)
{
rotation
(
view
.
layer
,
rotations
:
rotation
s
,
duration
:
duration
,
completion
:
completion
)
public
static
func
cornerRadius
(
view
:
UIView
,
radius
:
CGFloat
,
duration
:
CFTimeInterval
=
0.2
5
,
completion
:
(()
->
Void
)?
=
nil
)
{
cornerRadius
(
view
.
layer
,
radius
:
radiu
s
,
duration
:
duration
,
completion
:
completion
)
}
/**
:name:
rotation
:name:
cornerRadius
*/
public
static
func
rotation
(
layer
:
CALayer
,
rotations
:
Int
=
1
,
duration
:
CFTimeInterval
=
0.
5
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CABasicAnimation
=
rotationAnimation
(
rotation
s
)
public
static
func
cornerRadius
(
layer
:
CALayer
,
radius
:
CGFloat
,
duration
:
CFTimeInterval
=
0.2
5
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CABasicAnimation
=
cornerRadiusAnimation
(
radiu
s
)
animation
.
duration
=
duration
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
}
/**
:name:
transform
Animation
:name:
rotation
Animation
*/
public
static
func
transformAnimation
(
scale
:
CATransform3D
)
->
CABasicAnimation
{
public
static
func
rotationAnimation
(
rotations
:
Int
=
1
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
()
animation
.
keyPath
=
"transform"
animation
.
toValue
=
NSValue
(
CATransform3D
:
scale
)
animation
.
keyPath
=
"transform
.rotation
"
animation
.
byValue
=
M_PI
*
2
*
Double
(
rotations
)
return
animation
}
/**
:name:
transform
:name:
rotation
*/
public
static
func
transform
(
view
:
UIView
,
rotations
:
Int
=
1
,
duration
:
CFTimeInterval
=
0.2
5
,
completion
:
(()
->
Void
)?
=
nil
)
{
public
static
func
rotation
(
view
:
UIView
,
rotations
:
Int
=
1
,
duration
:
CFTimeInterval
=
0.
5
,
completion
:
(()
->
Void
)?
=
nil
)
{
rotation
(
view
.
layer
,
rotations
:
rotations
,
duration
:
duration
,
completion
:
completion
)
}
/**
:name:
transform
:name:
rotation
*/
public
static
func
transform
(
layer
:
CALayer
,
scale
:
CATransform3D
,
duration
:
CFTimeInterval
=
0.2
5
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CABasicAnimation
=
transformAnimation
(
scale
)
public
static
func
rotation
(
layer
:
CALayer
,
rotations
:
Int
=
1
,
duration
:
CFTimeInterval
=
0.
5
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CABasicAnimation
=
rotationAnimation
(
rotations
)
animation
.
duration
=
duration
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
}
/**
:name:
cornerRadius
Animation
:name:
scale
Animation
*/
public
static
func
cornerRadiusAnimation
(
radius
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
scaleAnimation
(
transform
:
CATransform3D
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
()
animation
.
keyPath
=
"
cornerRadius
"
animation
.
toValue
=
radius
animation
.
keyPath
=
"
transform.scale
"
animation
.
toValue
=
NSValue
(
CATransform3D
:
transform
)
return
animation
}
/**
:name:
cornerRadius
:name:
scale
*/
public
static
func
cornerRadius
(
view
:
UIView
,
radius
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
cornerRadius
(
view
.
layer
,
radius
:
radius
,
duration
:
duration
,
completion
:
completion
)
public
static
func
scale
(
view
:
UIView
,
transform
:
CATransform3D
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
scale
(
view
.
layer
,
transform
:
transform
,
duration
:
duration
,
completion
:
completion
)
}
/**
:name:
cornerRadius
:name:
scale
*/
public
static
func
cornerRadius
(
layer
:
CALayer
,
radius
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CABasicAnimation
=
cornerRadiusAnimation
(
radius
)
public
static
func
scale
(
layer
:
CALayer
,
transform
:
CATransform3D
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CABasicAnimation
=
scaleAnimation
(
transform
)
animation
.
duration
=
duration
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
}
...
...
Source/MaterialButton.swift
View file @
3ddfac11
...
...
@@ -222,6 +222,18 @@ public class MaterialButton : UIButton {
}
/**
:name: position
*/
public
var
position
:
CGPoint
{
get
{
return
layer
.
position
}
set
(
value
)
{
layer
.
position
=
value
}
}
/**
:name: zPosition
*/
public
var
zPosition
:
CGFloat
!
{
...
...
@@ -297,8 +309,8 @@ public class MaterialButton : UIButton {
})
pulseLayer
.
hidden
=
false
MaterialAnimation
.
transform
(
pulseLayer
,
scale
:
CATransform3DMakeScale
(
3
,
3
,
3
)
)
MaterialAnimation
.
transform
(
layer
,
scale
:
CATransform3DMakeScale
(
1.05
,
1.05
,
1.05
)
)
pulseLayer
.
transform
=
CATransform3DMakeScale
(
3
,
3
,
3
)
layer
.
transform
=
CATransform3DMakeScale
(
1.05
,
1.05
,
1.05
)
}
/**
...
...
@@ -363,7 +375,7 @@ public class MaterialButton : UIButton {
//
internal
func
shrink
()
{
pulseLayer
.
hidden
=
true
MaterialAnimation
.
transform
(
pulseLayer
,
scale
:
CATransform3DIdentity
)
MaterialAnimation
.
transform
(
layer
,
scale
:
CATransform3DIdentity
)
pulseLayer
.
transform
=
CATransform3DIdentity
layer
.
transform
=
CATransform3DIdentity
}
}
\ No newline at end of file
Source/MaterialKeyframeAnimation.swift
View file @
3ddfac11
...
...
@@ -42,28 +42,28 @@ public func MaterialAnimationRotationModeToValue(mode: MaterialAnimationRotation
public
extension
MaterialAnimation
{
/**
:name: p
ositionAnimation
:name: p
ath
*/
public
static
func
p
ositionAnimation
(
p
ath
:
UIBezierPath
,
mode
:
MaterialAnimationRotationMode
=
.
Auto
)
->
CAKeyframeAnimation
{
public
static
func
p
athAnimation
(
bezierP
ath
:
UIBezierPath
,
mode
:
MaterialAnimationRotationMode
=
.
Auto
)
->
CAKeyframeAnimation
{
let
animation
:
CAKeyframeAnimation
=
CAKeyframeAnimation
()
animation
.
keyPath
=
"position"
animation
.
path
=
p
ath
.
CGPath
animation
.
path
=
bezierP
ath
.
CGPath
animation
.
rotationMode
=
MaterialAnimationRotationModeToValue
(
mode
)
return
animation
}
/**
:name: p
osition
:name: p
ath
*/
public
static
func
p
osition
(
view
:
UIView
,
p
ath
:
UIBezierPath
,
mode
:
MaterialAnimationRotationMode
=
.
Auto
,
duration
:
CFTimeInterval
=
1
)
{
p
osition
(
view
.
layer
,
path
:
p
ath
,
mode
:
mode
,
duration
:
duration
)
public
static
func
p
ath
(
view
:
UIView
,
bezierP
ath
:
UIBezierPath
,
mode
:
MaterialAnimationRotationMode
=
.
Auto
,
duration
:
CFTimeInterval
=
1
)
{
p
ath
(
view
.
layer
,
bezierPath
:
bezierP
ath
,
mode
:
mode
,
duration
:
duration
)
}
/**
:name: p
osition
:name: p
ath
*/
public
static
func
p
osition
(
layer
:
CALayer
,
p
ath
:
UIBezierPath
,
mode
:
MaterialAnimationRotationMode
=
.
Auto
,
duration
:
CFTimeInterval
=
1
)
{
let
animation
:
CAKeyframeAnimation
=
p
ositionAnimation
(
p
ath
,
mode
:
mode
)
public
static
func
p
ath
(
layer
:
CALayer
,
bezierP
ath
:
UIBezierPath
,
mode
:
MaterialAnimationRotationMode
=
.
Auto
,
duration
:
CFTimeInterval
=
1
)
{
let
animation
:
CAKeyframeAnimation
=
p
athAnimation
(
bezierP
ath
,
mode
:
mode
)
animation
.
duration
=
duration
applyKeyframeAnimation
(
animation
,
toLayer
:
layer
)
}
...
...
Source/MaterialPulseView.swift
View file @
3ddfac11
...
...
@@ -80,8 +80,8 @@ public class MaterialPulseView : MaterialView {
})
pulseLayer
.
hidden
=
false
MaterialAnimation
.
transform
(
pulseLayer
,
scale
:
CATransform3DMakeScale
(
3
,
3
,
3
)
)
MaterialAnimation
.
transform
(
layer
,
scale
:
CATransform3DMakeScale
(
1.05
,
1.05
,
1.05
)
)
pulseLayer
.
transform
=
CATransform3DMakeScale
(
3
,
3
,
3
)
layer
.
transform
=
CATransform3DMakeScale
(
1.05
,
1.05
,
1.05
)
}
/**
...
...
@@ -151,7 +151,7 @@ public class MaterialPulseView : MaterialView {
//
internal
func
shrink
()
{
pulseLayer
.
hidden
=
true
MaterialAnimation
.
transform
(
pulseLayer
,
scale
:
CATransform3DIdentity
)
MaterialAnimation
.
transform
(
layer
,
scale
:
CATransform3DIdentity
)
pulseLayer
.
transform
=
CATransform3DIdentity
layer
.
transform
=
CATransform3DIdentity
}
}
Source/MaterialView.swift
View file @
3ddfac11
...
...
@@ -238,6 +238,18 @@ public class MaterialView : UIView {
}
/**
:name: position
*/
public
var
position
:
CGPoint
{
get
{
return
layer
.
position
}
set
(
value
)
{
layer
.
position
=
value
}
}
/**
:name: zPosition
*/
public
var
zPosition
:
CGFloat
!
{
...
...
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