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 | function SwipeBackGesture(plt, _nav, gestureCtlr, domCtrl) {
|
20 | var _this = _super.call(this, plt, plt.doc().body, {
|
21 | direction: 'x',
|
22 | edge: 'start',
|
23 | maxEdgeStart: 75,
|
24 | threshold: 5,
|
25 | zone: false,
|
26 | domController: domCtrl,
|
27 | gesture: gestureCtlr.createGesture({
|
28 | name: GESTURE_GO_BACK_SWIPE,
|
29 | priority: GESTURE_PRIORITY_GO_BACK_SWIPE,
|
30 | disableScroll: true
|
31 | })
|
32 | }) || this;
|
33 | _this._nav = _nav;
|
34 | return _this;
|
35 | }
|
36 | SwipeBackGesture.prototype.canStart = function (ev) {
|
37 |
|
38 |
|
39 |
|
40 | return (this._nav.canSwipeBack() &&
|
41 | _super.prototype.canStart.call(this, ev));
|
42 | };
|
43 | SwipeBackGesture.prototype.onSlideBeforeStart = function (_ev) {
|
44 | this._nav.swipeBackStart();
|
45 | };
|
46 | SwipeBackGesture.prototype.onSlide = function (slide, ev) {
|
47 | ev.preventDefault();
|
48 | ev.stopPropagation();
|
49 | var stepValue = (slide.distance / slide.max);
|
50 | this._nav.swipeBackProgress(stepValue);
|
51 | };
|
52 | SwipeBackGesture.prototype.onSlideEnd = function (slide, _ev) {
|
53 | var velocity = slide.velocity;
|
54 | var currentStepValue = (slide.distance / slide.max);
|
55 | var isResetDirecction = velocity < 0;
|
56 | var isMovingFast = Math.abs(slide.velocity) > 0.4;
|
57 | var isInResetZone = Math.abs(slide.delta) < Math.abs(slide.max) * 0.5;
|
58 | var shouldComplete = !swipeShouldReset(isResetDirecction, isMovingFast, isInResetZone);
|
59 | this._nav.swipeBackEnd(shouldComplete, currentStepValue, velocity);
|
60 | };
|
61 | return SwipeBackGesture;
|
62 | }(SlideEdgeGesture));
|
63 | export { SwipeBackGesture };
|
64 |
|
\ | No newline at end of file |