Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Motion
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
Motion
Commits
398021c6
Unverified
Commit
398021c6
authored
Jun 06, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated Motion+Array and Motion+CALayer
parent
1127ed5a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
35 deletions
+81
-35
Sources/Extensions/Motion+Array.swift
+65
-25
Sources/Extensions/Motion+CALayer.swift
+16
-10
No files found.
Sources/Extensions/Motion+Array.swift
View file @
398021c6
...
@@ -29,37 +29,77 @@
...
@@ -29,37 +29,77 @@
import
UIKit
import
UIKit
internal
extension
Array
{
internal
extension
Array
{
func
get
(
_
index
:
Int
)
->
Element
?
{
/**
if
index
<
count
{
Retrieves the element at the given index if it exists.
return
self
[
index
]
- Parameter _ index: An Int.
- Returns: An optional Element value.
*/
func
get
(
_
index
:
Int
)
->
Element
?
{
if
index
<
count
{
return
self
[
index
]
}
return
nil
}
}
return
nil
}
}
}
internal
extension
Array
where
Element
:
ExprNode
{
internal
extension
Array
where
Element
:
ExprNode
{
func
getCGFloat
(
_
index
:
Int
)
->
CGFloat
?
{
/**
if
let
s
=
get
(
index
)
as?
NumberNode
{
Retrieves the element at the given index if it exists
return
CGFloat
(
s
.
value
)
as a CGFloat.
- Parameter _ index: An Int.
- Returns: An optional CGFloat value.
*/
func
getCGFloat
(
_
index
:
Int
)
->
CGFloat
?
{
guard
let
s
=
get
(
index
)
as?
NumberNode
else
{
return
nil
}
return
CGFloat
(
s
.
value
)
}
}
return
nil
}
/**
func
getDouble
(
_
index
:
Int
)
->
Double
?
{
Retrieves the element at the given index if it exists
if
let
s
=
get
(
index
)
as?
NumberNode
{
as a Double.
return
Double
(
s
.
value
)
- Parameter _ index: An Int.
- Returns: An optional Double value.
*/
func
getDouble
(
_
index
:
Int
)
->
Double
?
{
guard
let
s
=
get
(
index
)
as?
NumberNode
else
{
return
nil
}
return
Double
(
s
.
value
)
}
}
return
nil
}
/**
func
getFloat
(
_
index
:
Int
)
->
Float
?
{
Retrieves the element at the given index if it exists
if
let
s
=
get
(
index
)
as?
NumberNode
{
as a Float.
return
s
.
value
- Parameter _ index: An Int.
- Returns: An optional Float value.
*/
func
getFloat
(
_
index
:
Int
)
->
Float
?
{
guard
let
s
=
get
(
index
)
as?
NumberNode
else
{
return
nil
}
return
s
.
value
}
}
return
nil
}
/**
func
getBool
(
_
index
:
Int
)
->
Bool
?
{
Retrieves the element at the given index if it exists
if
let
s
=
get
(
index
)
as?
VariableNode
,
let
f
=
Bool
(
s
.
name
)
{
as a Bool.
return
f
- Parameter _ index: An Int.
- Returns: An optional Bool value.
*/
func
getBool
(
_
index
:
Int
)
->
Bool
?
{
guard
let
s
=
get
(
index
)
as?
VariableNode
else
{
return
nil
}
guard
let
f
=
Bool
(
s
.
name
)
else
{
return
nil
}
return
f
}
}
return
nil
}
}
}
Sources/Extensions/Motion+CALayer.swift
View file @
398021c6
...
@@ -28,20 +28,22 @@
...
@@ -28,20 +28,22 @@
import
UIKit
import
UIKit
@available(iOS 10, *)
extension
CALayer
:
CAAnimationDelegate
{}
internal
extension
CALayer
{
internal
extension
CALayer
{
// return all animations running by this layer.
/// Retrieves all currently running animations for the layer.
// the returned value is mutable
var
animations
:
[(
String
,
CAAnimation
)]
{
var
animations
:
[(
String
,
CAAnimation
)]
{
guard
let
keys
=
animationKeys
()
else
{
if
let
keys
=
animationKeys
()
{
return
[]
return
keys
.
map
{
return
(
$0
,
self
.
animation
(
forKey
:
$0
)
!.
copy
()
as!
CAAnimation
)
}
}
return
keys
.
map
{
return
(
$0
,
self
.
animation
(
forKey
:
$0
)
!.
copy
()
as!
CAAnimation
)
}
}
}
return
[]
}
}
}
@available(iOS 10, *)
extension
CALayer
:
CAAnimationDelegate
{}
extension
CALayer
{
extension
CALayer
{
/**
/**
A function that accepts CAAnimation objects and executes them on the
A function that accepts CAAnimation objects and executes them on the
...
@@ -77,6 +79,10 @@ extension CALayer {
...
@@ -77,6 +79,10 @@ extension CALayer {
}
}
}
}
/**
Executed when an animation has started.
- Parameter _ anim: A CAAnimation.
*/
public
func
animationDidStart
(
_
anim
:
CAAnimation
)
{}
public
func
animationDidStart
(
_
anim
:
CAAnimation
)
{}
/**
/**
...
...
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