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
1e63fdbd
Unverified
Commit
1e63fdbd
authored
Jan 22, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: added transitionView to MotionTransition animations
parent
e46c5a84
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
9 deletions
+82
-9
Sources/iOS/Material+UIView.swift
+33
-0
Sources/iOS/MotionAnimation.swift
+49
-9
Sources/iOS/MotionTransition.swift
+0
-0
No files found.
Sources/iOS/Material+UIView.swift
View file @
1e63fdbd
...
@@ -32,6 +32,39 @@ import UIKit
...
@@ -32,6 +32,39 @@ import UIKit
/// Grid extension for UIView.
/// Grid extension for UIView.
extension
UIView
{
extension
UIView
{
/// A property that accesses the backing layer's masksToBounds.
@IBInspectable
open
var
masksToBounds
:
Bool
{
get
{
return
layer
.
masksToBounds
}
set
(
value
)
{
layer
.
masksToBounds
=
value
}
}
/// A property that accesses the backing layer's opacity.
@IBInspectable
open
var
opacity
:
Float
{
get
{
return
layer
.
opacity
}
set
(
value
)
{
layer
.
opacity
=
value
}
}
/// A property that accesses the backing layer's anchorPoint.
@IBInspectable
open
var
anchorPoint
:
CGPoint
{
get
{
return
layer
.
anchorPoint
}
set
(
value
)
{
layer
.
anchorPoint
=
value
}
}
/// A property that accesses the frame.origin.x property.
/// A property that accesses the frame.origin.x property.
@IBInspectable
@IBInspectable
open
var
x
:
CGFloat
{
open
var
x
:
CGFloat
{
...
...
Sources/iOS/MotionAnimation.swift
View file @
1e63fdbd
...
@@ -52,6 +52,7 @@ public enum MotionAnimationKeyPath: String {
...
@@ -52,6 +52,7 @@ public enum MotionAnimationKeyPath: String {
case
zPosition
case
zPosition
case
width
=
"bounds.size.width"
case
width
=
"bounds.size.width"
case
height
=
"bounds.size.height"
case
height
=
"bounds.size.height"
case
size
=
"bounds.size"
}
}
public
enum
MotionAnimation
{
public
enum
MotionAnimation
{
...
@@ -87,6 +88,7 @@ public enum MotionAnimation {
...
@@ -87,6 +88,7 @@ public enum MotionAnimation {
case
zPosition
(
Int
)
case
zPosition
(
Int
)
case
width
(
CGFloat
)
case
width
(
CGFloat
)
case
height
(
CGFloat
)
case
height
(
CGFloat
)
case
size
(
CGSize
)
}
}
extension
CALayer
{
extension
CALayer
{
...
@@ -190,6 +192,22 @@ extension CALayer {
...
@@ -190,6 +192,22 @@ extension CALayer {
var
tf
=
timingFunction
var
tf
=
timingFunction
var
d
=
duration
var
d
=
duration
var
px
:
CGFloat
=
s
.
position
.
x
var
py
:
CGFloat
=
s
.
position
.
y
for
v
in
animations
{
switch
v
{
case
let
.
x
(
x
):
px
=
x
+
w
/
2
case
let
.
y
(
y
):
py
=
y
+
h
/
2
case
let
.
point
(
x
,
y
):
px
=
x
+
w
/
2
py
=
y
+
h
/
2
default
:
break
}
}
for
v
in
animations
{
for
v
in
animations
{
switch
v
{
switch
v
{
case
let
.
timingFunction
(
timingFunction
):
case
let
.
timingFunction
(
timingFunction
):
...
@@ -239,12 +257,9 @@ extension CALayer {
...
@@ -239,12 +257,9 @@ extension CALayer {
a
.
append
(
Motion
.
translateY
(
to
:
to
))
a
.
append
(
Motion
.
translateY
(
to
:
to
))
case
let
.
translateZ
(
to
):
case
let
.
translateZ
(
to
):
a
.
append
(
Motion
.
translateZ
(
to
:
to
))
a
.
append
(
Motion
.
translateZ
(
to
:
to
))
case
let
.
x
(
x
):
case
let
.
x
(
_
),
.
y
(
_
),
.
point
(
_
,
_
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
x
+
w
/
2
,
y
:
s
.
position
.
y
)))
let
position
=
Motion
.
position
(
to
:
CGPoint
(
x
:
px
,
y
:
py
))
case
let
.
y
(
y
):
a
.
append
(
position
)
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
s
.
position
.
x
,
y
:
y
+
h
/
2
)))
case
let
.
point
(
x
,
y
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
x
+
w
/
2
,
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
):
...
@@ -261,6 +276,8 @@ extension CALayer {
...
@@ -261,6 +276,8 @@ extension CALayer {
a
.
append
(
Motion
.
width
(
w
))
a
.
append
(
Motion
.
width
(
w
))
case
let
.
height
(
h
):
case
let
.
height
(
h
):
a
.
append
(
Motion
.
height
(
h
))
a
.
append
(
Motion
.
height
(
h
))
case
let
.
size
(
size
):
a
.
append
(
Motion
.
size
(
size
))
default
:
break
default
:
break
}
}
}
}
...
@@ -523,14 +540,26 @@ extension Motion {
...
@@ -523,14 +540,26 @@ extension Motion {
/**
/**
Creates a CABasicAnimation for the position key path.
Creates a CABasicAnimation for the position key path.
- Parameter to point: A CGPoint.
- Parameter x: A CGFloat.
- Parameter y: A CGFloat.
- Returns: A CABasicAnimation.
- Returns: A CABasicAnimation.
*/
*/
public
static
func
position
(
to
point
:
CGPoin
t
)
->
CABasicAnimation
{
public
static
func
position
(
x
:
CGFloat
,
y
:
CGFloa
t
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
position
)
let
animation
=
CABasicAnimation
(
keyPath
:
.
position
)
animation
.
toValue
=
NSValue
(
cgPoint
:
point
)
animation
.
toValue
=
NSValue
(
cgPoint
:
CGPoint
(
x
:
x
,
y
:
y
)
)
return
animation
return
animation
}
}
/**
Creates a CABasicAnimation for the position key path.
- Parameter to point: A CGPoint.
- Returns: A CABasicAnimation.
*/
public
static
func
position
(
to
point
:
CGPoint
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
position
)
animation
.
toValue
=
NSValue
(
cgPoint
:
point
)
return
animation
}
/**
/**
Creates a CABasicAnimation for the shadowPath key path.
Creates a CABasicAnimation for the shadowPath key path.
...
@@ -586,4 +615,15 @@ extension Motion {
...
@@ -586,4 +615,15 @@ extension Motion {
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
height
))
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
height
))
return
animation
return
animation
}
}
/**
Creates a CABasicaAnimation for the height key path.
- Parameter size: A CGSize.
- Returns: A CABasicAnimation.
*/
public
static
func
size
(
_
size
:
CGSize
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
size
)
animation
.
toValue
=
NSValue
(
cgSize
:
size
)
return
animation
}
}
}
Sources/iOS/MotionTransition.swift
View file @
1e63fdbd
This diff is collapsed.
Click to expand it.
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