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
b5414c6b
Commit
b5414c6b
authored
Jan 26, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updating threshold for pan gesture on SideNav
parent
e76b1a27
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
15 deletions
+25
-15
Sources/SideNavigationViewController.swift
+25
-15
No files found.
Sources/SideNavigationViewController.swift
View file @
b5414c6b
...
@@ -111,13 +111,13 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
...
@@ -111,13 +111,13 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
A UIPanGestureRecognizer property internally used for the
A UIPanGestureRecognizer property internally used for the
pan gesture.
pan gesture.
*/
*/
private
var
sideP
anGesture
:
UIPanGestureRecognizer
?
private
var
p
anGesture
:
UIPanGestureRecognizer
?
/**
/**
A UITapGestureRecognizer property internally used for the
A UITapGestureRecognizer property internally used for the
tap gesture.
tap gesture.
*/
*/
private
var
sideT
apGesture
:
UITapGestureRecognizer
?
private
var
t
apGesture
:
UITapGestureRecognizer
?
/**
/**
A CAShapeLayer property that is used as the backdrop when
A CAShapeLayer property that is used as the backdrop when
...
@@ -128,14 +128,24 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
...
@@ -128,14 +128,24 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
public
private(set)
lazy
var
backdropLayer
:
CAShapeLayer
=
CAShapeLayer
()
public
private(set)
lazy
var
backdropLayer
:
CAShapeLayer
=
CAShapeLayer
()
/**
/**
A CGFloat property that accesses the
horizontal
threshold of
A CGFloat property that accesses the
leftView
threshold of
the SideNavigationViewController. When the panning gesture has
the SideNavigationViewController. When the panning gesture has
ended, if the position is beyond the
horizontal
threshold,
ended, if the position is beyond the threshold,
the leftView is opened, if it is below the threshold, the
the leftView is opened, if it is below the threshold, the
leftView is closed. The
horizontal t
hreshold is always at half
leftView is closed. The
leftViewT
hreshold is always at half
the width of the leftView.
the width of the leftView.
*/
*/
public
private(set)
var
horizontalThreshold
:
CGFloat
=
0
public
private(set)
var
leftViewThreshold
:
CGFloat
=
0
/**
A CGFloat property that accesses the rightView threshold of
the SideNavigationViewController. When the panning gesture has
ended, if the position is beyond the threshold,
the rightView is closed, if it is below the threshold, the
rightView is opened. The rightViewThreshold is always at half
the width of the rightView.
*/
public
private(set)
var
rightViewThreshold
:
CGFloat
=
0
/**
/**
A SideNavigationViewControllerDelegate property used to bind
A SideNavigationViewControllerDelegate property used to bind
...
@@ -169,10 +179,10 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
...
@@ -169,10 +179,10 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
public
var
enabled
:
Bool
=
true
{
public
var
enabled
:
Bool
=
true
{
didSet
{
didSet
{
if
enabled
{
if
enabled
{
removeGestures
(
&
sidePanGesture
,
tap
:
&
sideT
apGesture
)
removeGestures
(
&
panGesture
,
tap
:
&
t
apGesture
)
prepareGestures
(
&
sidePanGesture
,
panSelector
:
"handlePanGesture:"
,
tap
:
&
sideT
apGesture
,
tapSelector
:
"handleTapGesture:"
)
prepareGestures
(
&
panGesture
,
panSelector
:
"handlePanGesture:"
,
tap
:
&
t
apGesture
,
tapSelector
:
"handleTapGesture:"
)
}
else
{
}
else
{
removeGestures
(
&
sidePanGesture
,
tap
:
&
sideT
apGesture
)
removeGestures
(
&
panGesture
,
tap
:
&
t
apGesture
)
}
}
}
}
}
}
...
@@ -501,10 +511,10 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
...
@@ -501,10 +511,10 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
public
func
gestureRecognizer
(
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceiveTouch
touch
:
UITouch
)
->
Bool
{
public
func
gestureRecognizer
(
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceiveTouch
touch
:
UITouch
)
->
Bool
{
if
enabled
{
if
enabled
{
if
gestureRecognizer
==
sideP
anGesture
{
if
gestureRecognizer
==
p
anGesture
{
return
opened
||
enabled
&&
isPointContainedWithinRect
(
touch
.
locationInView
(
view
))
return
enabled
&&
isPointContainedWithinLeftThreshold
(
touch
.
locationInView
(
view
))
}
}
if
opened
&&
gestureRecognizer
==
sideT
apGesture
{
if
opened
&&
gestureRecognizer
==
t
apGesture
{
let
point
:
CGPoint
=
touch
.
locationInView
(
view
)
let
point
:
CGPoint
=
touch
.
locationInView
(
view
)
delegate
?
.
sideNavigationViewDidTap
?(
self
,
point
:
point
)
delegate
?
.
sideNavigationViewDidTap
?(
self
,
point
:
point
)
return
!
isPointContainedWithinViewController
(
leftView
!
,
point
:
point
)
return
!
isPointContainedWithinViewController
(
leftView
!
,
point
:
point
)
...
@@ -614,8 +624,8 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
...
@@ -614,8 +624,8 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
}
prepareLeftViewController
()
prepareLeftViewController
()
removeGestures
(
&
sidePanGesture
,
tap
:
&
sideT
apGesture
)
removeGestures
(
&
panGesture
,
tap
:
&
t
apGesture
)
prepareGestures
(
&
sidePanGesture
,
panSelector
:
"handlePanGesture:"
,
tap
:
&
sideT
apGesture
,
tapSelector
:
"handleTapGesture:"
)
prepareGestures
(
&
panGesture
,
panSelector
:
"handlePanGesture:"
,
tap
:
&
t
apGesture
,
tapSelector
:
"handleTapGesture:"
)
}
}
/**
/**
...
@@ -710,7 +720,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
...
@@ -710,7 +720,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
- Returns: A Boolean of the result, true if yes, false
- Returns: A Boolean of the result, true if yes, false
otherwise.
otherwise.
*/
*/
private
func
isPointContainedWithin
Rect
(
point
:
CGPoint
)
->
Bool
{
private
func
isPointContainedWithin
LeftThreshold
(
point
:
CGPoint
)
->
Bool
{
return
CGRectContainsPoint
(
CGRectMake
(
0
,
0
,
horizontalThreshold
,
view
.
frame
.
height
),
point
)
return
CGRectContainsPoint
(
CGRectMake
(
0
,
0
,
horizontalThreshold
,
view
.
frame
.
height
),
point
)
}
}
...
...
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