1 | var __extends = (this && this.__extends) || (function () {
|
2 | var extendStatics = Object.setPrototypeOf ||
|
3 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
4 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
5 | return function (d, b) {
|
6 | extendStatics(d, b);
|
7 | function __() { this.constructor = d; }
|
8 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
9 | };
|
10 | })();
|
11 | import { swipeShouldReset } from '../util/util';
|
12 | import { GESTURE_GO_BACK_SWIPE, GESTURE_PRIORITY_GO_BACK_SWIPE } from '../gestures/gesture-controller';
|
13 | import { SlideEdgeGesture } from '../gestures/slide-edge-gesture';
|
14 |
|
15 |
|
16 |
|
17 | var SwipeBackGesture = (function (_super) {
|
18 | __extends(SwipeBackGesture, _super);
|
19 | |
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | function SwipeBackGesture(plt, _nav, gestureCtlr, domCtrl) {
|
26 | var _this = _super.call(this, plt, plt.doc().body, {
|
27 | direction: 'x',
|
28 | edge: 'start',
|
29 | maxEdgeStart: 75,
|
30 | threshold: 5,
|
31 | zone: false,
|
32 | domController: domCtrl,
|
33 | gesture: gestureCtlr.createGesture({
|
34 | name: GESTURE_GO_BACK_SWIPE,
|
35 | priority: GESTURE_PRIORITY_GO_BACK_SWIPE,
|
36 | disableScroll: true
|
37 | })
|
38 | }) || this;
|
39 | _this._nav = _nav;
|
40 | return _this;
|
41 | }
|
42 | |
43 |
|
44 |
|
45 |
|
46 | SwipeBackGesture.prototype.canStart = function (ev) {
|
47 |
|
48 |
|
49 |
|
50 | return (this._nav.canSwipeBack() &&
|
51 | _super.prototype.canStart.call(this, ev));
|
52 | };
|
53 | |
54 |
|
55 |
|
56 |
|
57 | SwipeBackGesture.prototype.onSlideBeforeStart = function (_ev) {
|
58 | this._nav.swipeBackStart();
|
59 | };
|
60 | |
61 |
|
62 |
|
63 |
|
64 |
|
65 | SwipeBackGesture.prototype.onSlide = function (slide, ev) {
|
66 | ev.preventDefault();
|
67 | ev.stopPropagation();
|
68 | var stepValue = (slide.distance / slide.max);
|
69 | this._nav.swipeBackProgress(stepValue);
|
70 | };
|
71 | |
72 |
|
73 |
|
74 |
|
75 |
|
76 | SwipeBackGesture.prototype.onSlideEnd = function (slide, _ev) {
|
77 | var velocity = slide.velocity;
|
78 | var currentStepValue = (slide.distance / slide.max);
|
79 | var isResetDirecction = velocity < 0;
|
80 | var isMovingFast = Math.abs(slide.velocity) > 0.4;
|
81 | var isInResetZone = Math.abs(slide.delta) < Math.abs(slide.max) * 0.5;
|
82 | var shouldComplete = !swipeShouldReset(isResetDirecction, isMovingFast, isInResetZone);
|
83 | this._nav.swipeBackEnd(shouldComplete, currentStepValue, velocity);
|
84 | };
|
85 | return SwipeBackGesture;
|
86 | }(SlideEdgeGesture));
|
87 | export { SwipeBackGesture };
|
88 | function SwipeBackGesture_tsickle_Closure_declarations() {
|
89 |
|
90 | SwipeBackGesture.prototype._nav;
|
91 | }
|
92 |
|
\ | No newline at end of file |