FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ionic/ionic/components/nav/swipe-back.ts at angular-rc1 · Java1024/ionic · GitHub
Java1024
ionic
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ionic
/
ionic
/
components
/
nav
/
swipe-back.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
57 lines (45 loc) · 1.66 KB
Breadcrumbs
ionic
/
ionic
/
components
/
nav
/
swipe-back.ts
Copy path
File metadata and controls
57 lines (45 loc) · 1.66 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import
{
NavController
}
from
'./nav-controller'
;
import
{
SlideEdgeGesture
}
from
'../../gestures/slide-edge-gesture'
;
import
{
SlideData
}
from
'../../gestures/slide-gesture'
;
import
{
assign
}
from
'../../util/util'
;
export
class
SwipeBackGesture
extends
SlideEdgeGesture
{
constructor
(
element
:
HTMLElement
,
options
:
any
,
private
_nav
:
NavController
)
{
super
(
element
,
assign
(
{
direction
:
'x'
,
maxEdgeStart
:
75
}
,
options
)
)
;
}
canStart
(
ev
:
any
)
{
// the gesture swipe angle must be mainly horizontal and the
// gesture distance would be relatively short for a swipe back
// and swipe back must be possible on this nav controller
if
(
ev
.
angle
>
-
40
&&
ev
.
angle
<
40
&&
ev
.
distance
<
50
&&
this
.
_nav
.
canSwipeBack
(
)
)
{
// passed the tests, now see if the super says it's cool or not
return
super
.
canStart
(
ev
)
;
}
// nerp, not today
return
false
;
}
onSlideBeforeStart
(
)
{
console
.
debug
(
'swipeBack, onSlideBeforeStart'
)
;
this
.
_nav
.
swipeBackStart
(
)
;
}
onSlide
(
slide
:
SlideData
)
{
let
stepValue
=
(
slide
.
distance
/
slide
.
max
)
;
console
.
debug
(
'swipeBack, onSlide, distance'
,
slide
.
distance
,
'max'
,
slide
.
max
,
'stepValue'
,
stepValue
)
;
this
.
_nav
.
swipeBackProgress
(
stepValue
)
;
}
onSlideEnd
(
slide
:
SlideData
,
ev
:
any
)
{
let
shouldComplete
=
(
Math
.
abs
(
ev
.
velocityX
)
>
0.2
||
Math
.
abs
(
slide
.
delta
)
>
Math
.
abs
(
slide
.
max
)
*
0.5
)
;
let
currentStepValue
=
(
slide
.
distance
/
slide
.
max
)
;
console
.
debug
(
'swipeBack, onSlideEnd, shouldComplete'
,
shouldComplete
,
'currentStepValue'
,
currentStepValue
)
;
this
.
_nav
.
swipeBackEnd
(
shouldComplete
,
currentStepValue
)
;
}
}
Back
|
FazBrowse Home
|
New Git URL