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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
17 deletions
+63
-17
Sources/Extensions/Motion+Array.swift
+49
-9
Sources/Extensions/Motion+CALayer.swift
+14
-8
No files found.
Sources/Extensions/Motion+Array.swift
View file @
398021c6
...
@@ -29,6 +29,11 @@
...
@@ -29,6 +29,11 @@
import
UIKit
import
UIKit
internal
extension
Array
{
internal
extension
Array
{
/**
Retrieves the element at the given index if it exists.
- Parameter _ index: An Int.
- Returns: An optional Element value.
*/
func
get
(
_
index
:
Int
)
->
Element
?
{
func
get
(
_
index
:
Int
)
->
Element
?
{
if
index
<
count
{
if
index
<
count
{
return
self
[
index
]
return
self
[
index
]
...
@@ -38,28 +43,63 @@ internal extension Array {
...
@@ -38,28 +43,63 @@ internal extension Array {
}
}
internal
extension
Array
where
Element
:
ExprNode
{
internal
extension
Array
where
Element
:
ExprNode
{
/**
Retrieves the element at the given index if it exists
as a CGFloat.
- Parameter _ index: An Int.
- Returns: An optional CGFloat value.
*/
func
getCGFloat
(
_
index
:
Int
)
->
CGFloat
?
{
func
getCGFloat
(
_
index
:
Int
)
->
CGFloat
?
{
if
let
s
=
get
(
index
)
as?
NumberNode
{
guard
let
s
=
get
(
index
)
as?
NumberNode
else
{
return
nil
}
return
CGFloat
(
s
.
value
)
return
CGFloat
(
s
.
value
)
}
}
/**
Retrieves the element at the given index if it exists
as a Double.
- 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
nil
}
}
func
getDouble
(
_
index
:
Int
)
->
Double
?
{
if
let
s
=
get
(
index
)
as?
NumberNode
{
return
Double
(
s
.
value
)
return
Double
(
s
.
value
)
}
}
/**
Retrieves the element at the given index if it exists
as a Float.
- 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
nil
}
}
func
getFloat
(
_
index
:
Int
)
->
Float
?
{
if
let
s
=
get
(
index
)
as?
NumberNode
{
return
s
.
value
return
s
.
value
}
}
return
nil
}
/**
Retrieves the element at the given index if it exists
as a Bool.
- Parameter _ index: An Int.
- Returns: An optional Bool value.
*/
func
getBool
(
_
index
:
Int
)
->
Bool
?
{
func
getBool
(
_
index
:
Int
)
->
Bool
?
{
if
let
s
=
get
(
index
)
as?
VariableNode
,
let
f
=
Bool
(
s
.
name
)
{
guard
let
s
=
get
(
index
)
as?
VariableNode
else
{
return
f
return
nil
}
}
guard
let
f
=
Bool
(
s
.
name
)
else
{
return
nil
return
nil
}
}
return
f
}
}
}
Sources/Extensions/Motion+CALayer.swift
View file @
398021c6
...
@@ -28,19 +28,21 @@
...
@@ -28,19 +28,21 @@
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
)]
{
if
let
keys
=
animationKeys
()
{
guard
let
keys
=
animationKeys
()
else
{
return
keys
.
map
{
return
(
$0
,
self
.
animation
(
forKey
:
$0
)
!.
copy
()
as!
CAAnimation
)
}
}
return
[]
return
[]
}
}
}
@available(iOS 10, *)
return
keys
.
map
{
extension
CALayer
:
CAAnimationDelegate
{}
return
(
$0
,
self
.
animation
(
forKey
:
$0
)
!.
copy
()
as!
CAAnimation
)
}
}
}
extension
CALayer
{
extension
CALayer
{
/**
/**
...
@@ -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