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
b5cecbfc
Commit
b5cecbfc
authored
Oct 02, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial KeyframeAnimation added to MaterialAnimation
parent
68026aad
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
166 additions
and
58 deletions
+166
-58
MaterialKit.xcodeproj/project.pbxproj
+8
-0
Source/MaterialAnimation.swift
+11
-58
Source/MaterialBasicAnimation.swift
+73
-0
Source/MaterialKeyframeAnimation.swift
+74
-0
No files found.
MaterialKit.xcodeproj/project.pbxproj
View file @
b5cecbfc
...
...
@@ -37,6 +37,8 @@
65BDD1741BB8D443006F7F2B
/* MaterialAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD1731BB8D443006F7F2B
/* MaterialAnimation.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
65BDD1791BB99C0F006F7F2B
/* RaisedButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD1781BB99C0F006F7F2B
/* RaisedButton.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
65BDD17C1BB99E29006F7F2B
/* FabButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD17B1BB99E29006F7F2B
/* FabButton.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
65D2BEC71BBED1E400800B7B
/* MaterialBasicAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65D2BEC61BBED1E400800B7B
/* MaterialBasicAnimation.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
65D2BEC91BBED1FA00800B7B
/* MaterialKeyframeAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65D2BEC81BBED1FA00800B7B
/* MaterialKeyframeAnimation.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
65DBE4201B9A9244000C804F
/* Roboto-Bold.ttf in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65DBE41E1B9A9244000C804F
/* Roboto-Bold.ttf */
;
};
65DBE4211B9A9244000C804F
/* Roboto-Thin.ttf in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65DBE41F1B9A9244000C804F
/* Roboto-Thin.ttf */
;
};
962F3E531BACA68C0004B8AD
/* NavigationBarView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
962F3E521BACA68C0004B8AD
/* NavigationBarView.swift */
;
};
...
...
@@ -90,6 +92,8 @@
65BDD1731BB8D443006F7F2B
/* MaterialAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialAnimation.swift
;
sourceTree
=
"<group>"
;
};
65BDD1781BB99C0F006F7F2B
/* RaisedButton.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
RaisedButton.swift
;
sourceTree
=
"<group>"
;
};
65BDD17B1BB99E29006F7F2B
/* FabButton.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
FabButton.swift
;
sourceTree
=
"<group>"
;
};
65D2BEC61BBED1E400800B7B
/* MaterialBasicAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialBasicAnimation.swift
;
sourceTree
=
"<group>"
;
};
65D2BEC81BBED1FA00800B7B
/* MaterialKeyframeAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialKeyframeAnimation.swift
;
sourceTree
=
"<group>"
;
};
65DBE41E1B9A9244000C804F
/* Roboto-Bold.ttf */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
"Roboto-Bold.ttf"
;
sourceTree
=
"<group>"
;
};
65DBE41F1B9A9244000C804F
/* Roboto-Thin.ttf */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
"Roboto-Thin.ttf"
;
sourceTree
=
"<group>"
;
};
962F3E521BACA68C0004B8AD
/* NavigationBarView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
NavigationBarView.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -179,6 +183,8 @@
isa
=
PBXGroup
;
children
=
(
65BDD1731BB8D443006F7F2B
/* MaterialAnimation.swift */
,
65D2BEC61BBED1E400800B7B
/* MaterialBasicAnimation.swift */
,
65D2BEC81BBED1FA00800B7B
/* MaterialKeyframeAnimation.swift */
,
);
name
=
Animation
;
sourceTree
=
"<group>"
;
...
...
@@ -442,6 +448,8 @@
65BDD15B1BB7095E006F7F2B
/* MaterialRadius.swift in Sources */
,
65BDD1721BB8CD77006F7F2B
/* MaterialLabel.swift in Sources */
,
65BDD1491BB5DC98006F7F2B
/* MaterialColor.swift in Sources */
,
65D2BEC91BBED1FA00800B7B
/* MaterialKeyframeAnimation.swift in Sources */
,
65D2BEC71BBED1E400800B7B
/* MaterialBasicAnimation.swift in Sources */
,
65BDD14D1BB5ED9F006F7F2B
/* MaterialTheme.swift in Sources */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
...
...
Source/MaterialAnimation.swift
View file @
b5cecbfc
...
...
@@ -20,64 +20,19 @@ import UIKit
public
struct
MaterialAnimation
{
/**
:name: backgroundColor
*/
public
static
func
backgroundColor
(
layer
:
CALayer
,
color
:
UIColor
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
()
animation
.
keyPath
=
"backgroundColor"
animation
.
duration
=
duration
animation
.
toValue
=
color
.
CGColor
applyBasicAnimation
(
animation
,
layer
:
layer
,
completion
:
completion
)
}
/**
:name: rotate
*/
public
static
func
rotate
(
layer
:
CALayer
,
rotations
:
Int
=
1
,
duration
:
CFTimeInterval
=
0.5
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
()
animation
.
keyPath
=
"transform.rotation"
animation
.
duration
=
duration
animation
.
byValue
=
M_PI
*
2
*
Double
(
rotations
)
applyBasicAnimation
(
animation
,
layer
:
layer
,
completion
:
completion
)
}
/**
:name: transform
*/
public
static
func
transform
(
layer
:
CALayer
,
scale
:
CATransform3D
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
()
animation
.
keyPath
=
"transform"
animation
.
duration
=
duration
animation
.
toValue
=
NSValue
(
CATransform3D
:
scale
)
applyBasicAnimation
(
animation
,
layer
:
layer
,
completion
:
completion
)
}
/**
:name: position
*/
public
static
func
position
(
layer
:
CALayer
,
point
:
CGPoint
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
()
animation
.
keyPath
=
"position"
animation
.
duration
=
duration
animation
.
toValue
=
NSValue
(
CGPoint
:
point
)
applyBasicAnimation
(
animation
,
layer
:
layer
,
completion
:
completion
)
}
/**
:name: cornerRadius
:name: disableAnimation
*/
public
static
func
cornerRadius
(
layer
:
CALayer
,
radius
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
()
animation
.
keyPath
=
"cornerRadius"
animation
.
duration
=
duration
animation
.
toValue
=
radius
applyBasicAnimation
(
animation
,
layer
:
layer
,
completion
:
completion
)
public
static
func
disableAnimation
(
block
:
(()
->
Void
))
{
CATransaction
.
begin
()
CATransaction
.
setAnimationDuration
(
0
)
block
()
CATransaction
.
commit
()
}
/**
:name: applyBasicAnimation
*/
public
static
func
applyBasicAnimation
(
animation
:
CABasicAnimation
,
layer
:
CALayer
,
completion
:
(()
->
Void
)?
=
nil
)
{
public
static
func
applyBasicAnimation
(
animation
:
CABasicAnimation
,
toLayer
layer
:
CALayer
,
completion
:
(()
->
Void
)?
=
nil
)
{
// use presentation layer if available
animation
.
fromValue
=
(
nil
==
layer
.
presentationLayer
()
?
layer
:
layer
.
presentationLayer
()
as!
CALayer
)
.
valueForKeyPath
(
animation
.
keyPath
!
)
CATransaction
.
begin
()
...
...
@@ -93,12 +48,10 @@ public struct MaterialAnimation {
}
/**
:name:
disabl
eAnimation
:name:
applyKeyfram
eAnimation
*/
public
static
func
disableAnimation
(
block
:
(()
->
Void
))
{
CATransaction
.
begin
()
CATransaction
.
setAnimationDuration
(
0
)
block
()
CATransaction
.
commit
()
public
static
func
applyKeyframeAnimation
(
animation
:
CAKeyframeAnimation
,
toLayer
layer
:
CALayer
,
completion
:
(()
->
Void
)?
=
nil
)
{
// use presentation layer if available
(
nil
==
layer
.
presentationLayer
()
?
layer
:
layer
.
presentationLayer
()
as!
CALayer
)
.
addAnimation
(
animation
,
forKey
:
nil
)
}
}
Source/MaterialBasicAnimation.swift
0 → 100644
View file @
b5cecbfc
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import
UIKit
public
extension
MaterialAnimation
{
/**
:name: backgroundColor
*/
public
static
func
backgroundColor
(
layer
:
CALayer
,
color
:
UIColor
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
()
animation
.
keyPath
=
"backgroundColor"
animation
.
duration
=
duration
animation
.
toValue
=
color
.
CGColor
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
}
/**
:name: rotate
*/
public
static
func
rotate
(
view
:
UIView
,
rotations
:
Int
=
1
,
duration
:
CFTimeInterval
=
0.5
,
completion
:
(()
->
Void
)?
=
nil
)
{
rotate
(
view
.
layer
,
rotations
:
rotations
,
duration
:
duration
,
completion
:
completion
)
}
/**
:name: rotate
*/
public
static
func
rotate
(
layer
:
CALayer
,
rotations
:
Int
=
1
,
duration
:
CFTimeInterval
=
0.5
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
()
animation
.
keyPath
=
"transform.rotation"
animation
.
duration
=
duration
animation
.
byValue
=
M_PI
*
2
*
Double
(
rotations
)
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
}
/**
:name: transform
*/
public
static
func
transform
(
layer
:
CALayer
,
scale
:
CATransform3D
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
()
animation
.
keyPath
=
"transform"
animation
.
duration
=
duration
animation
.
toValue
=
NSValue
(
CATransform3D
:
scale
)
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
}
/**
:name: cornerRadius
*/
public
static
func
cornerRadius
(
layer
:
CALayer
,
radius
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CABasicAnimation
=
CABasicAnimation
()
animation
.
keyPath
=
"cornerRadius"
animation
.
duration
=
duration
animation
.
byValue
=
radius
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
}
}
\ No newline at end of file
Source/MaterialKeyframeAnimation.swift
0 → 100644
View file @
b5cecbfc
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import
UIKit
public
typealias
MaterialAnimationRotationModeType
=
String
public
enum
MaterialAnimationRotationMode
{
case
None
case
Auto
case
AutoReverse
}
/**
:name: MaterialAnimationRotationModeToValue
*/
public
func
MaterialAnimationRotationModeToValue
(
mode
:
MaterialAnimationRotationMode
)
->
MaterialAnimationRotationModeType
?
{
switch
mode
{
case
.
None
:
return
nil
case
.
Auto
:
return
kCAAnimationRotateAuto
case
.
AutoReverse
:
return
kCAAnimationRotateAutoReverse
}
}
public
extension
MaterialAnimation
{
/**
:name: position
*/
public
static
func
position
(
view
:
UIView
,
path
:
UIBezierPath
,
mode
:
MaterialAnimationRotationMode
=
.
Auto
,
duration
:
CFTimeInterval
=
1
,
completion
:
(()
->
Void
)?
=
nil
)
{
position
(
view
.
layer
,
path
:
path
,
mode
:
mode
,
duration
:
duration
,
completion
:
completion
)
}
/**
:name: position
*/
public
static
func
position
(
layer
:
CALayer
,
path
:
UIBezierPath
,
mode
:
MaterialAnimationRotationMode
=
.
Auto
,
duration
:
CFTimeInterval
=
1
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
animation
:
CAKeyframeAnimation
=
CAKeyframeAnimation
()
animation
.
keyPath
=
"position"
animation
.
duration
=
duration
animation
.
path
=
path
.
CGPath
animation
.
rotationMode
=
MaterialAnimationRotationModeToValue
(
mode
)
applyKeyframeAnimation
(
animation
,
toLayer
:
layer
)
}
}
\ 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