-
Notifications
You must be signed in to change notification settings - Fork 68
/
ExNavigatorMixin.js
80 lines (62 loc) · 1.5 KB
/
ExNavigatorMixin.js
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
'use strict';
export default {
// Navigator methods
getCurrentRoutes() {
return this.__navigator.getCurrentRoutes();
},
jumpBack() {
return this.__navigator.jumpBack();
},
jumpForward() {
return this.__navigator.jumpForward();
},
jumpTo(route) {
return this.__navigator.jumpTo(route);
},
push(route) {
return this.__navigator.push(route);
},
pop() {
return this.__navigator.pop();
},
replace(route) {
return this.__navigator.replace(route);
},
replaceAtIndex(route, index) {
return this.__navigator.replaceAtIndex(route, index);
},
replacePrevious(route) {
return this.__navigator.replacePrevious(route);
},
resetTo(route) {
return this.__navigator.resetTo(route);
},
immediatelyResetRouteStack(routeStack) {
return this.__navigator.immediatelyResetRouteStack(routeStack);
},
popToRoute(route) {
return this.__navigator.popToRoute(route);
},
popToTop() {
return this.__navigator.popToTop();
},
replacePreviousAndPop(route) {
return this.__navigator.replacePreviousAndPop(route);
},
// Convenience methods
/**
* Replaces the top-most route with the given route and navigates to it
* with a pop transition
*/
transitionToTop(route) {
this.replaceAtIndex(route, 0);
this.popToTop();
},
/**
* Pops back `n` routes. That is, `pop()` behaves like `popBack(1)`.
*/
popBack(n) {
let routes = this.getCurrentRoutes();
this.popToRoute(routes[routes.length - n - 1]);
},
};