UNPKG

3.38 kBJavaScriptView Raw
1var __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})();
11import { swipeShouldReset } from '../util/util';
12import { GESTURE_GO_BACK_SWIPE, GESTURE_PRIORITY_GO_BACK_SWIPE } from '../gestures/gesture-controller';
13import { SlideEdgeGesture } from '../gestures/slide-edge-gesture';
14/**
15 * @hidden
16 */
17var SwipeBackGesture = (function (_super) {
18 __extends(SwipeBackGesture, _super);
19 /**
20 * @param {?} plt
21 * @param {?} _nav
22 * @param {?} gestureCtlr
23 * @param {?} domCtrl
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 * @param {?} ev
44 * @return {?}
45 */
46 SwipeBackGesture.prototype.canStart = function (ev) {
47 // the gesture swipe angle must be mainly horizontal and the
48 // gesture distance would be relatively short for a swipe back
49 // and swipe back must be possible on this nav controller
50 return (this._nav.canSwipeBack() &&
51 _super.prototype.canStart.call(this, ev));
52 };
53 /**
54 * @param {?} _ev
55 * @return {?}
56 */
57 SwipeBackGesture.prototype.onSlideBeforeStart = function (_ev) {
58 this._nav.swipeBackStart();
59 };
60 /**
61 * @param {?} slide
62 * @param {?} ev
63 * @return {?}
64 */
65 SwipeBackGesture.prototype.onSlide = function (slide, ev) {
66 ev.preventDefault();
67 ev.stopPropagation();
68 var /** @type {?} */ stepValue = (slide.distance / slide.max);
69 this._nav.swipeBackProgress(stepValue);
70 };
71 /**
72 * @param {?} slide
73 * @param {?} _ev
74 * @return {?}
75 */
76 SwipeBackGesture.prototype.onSlideEnd = function (slide, _ev) {
77 var /** @type {?} */ velocity = slide.velocity;
78 var /** @type {?} */ currentStepValue = (slide.distance / slide.max);
79 var /** @type {?} */ isResetDirecction = velocity < 0;
80 var /** @type {?} */ isMovingFast = Math.abs(slide.velocity) > 0.4;
81 var /** @type {?} */ isInResetZone = Math.abs(slide.delta) < Math.abs(slide.max) * 0.5;
82 var /** @type {?} */ shouldComplete = !swipeShouldReset(isResetDirecction, isMovingFast, isInResetZone);
83 this._nav.swipeBackEnd(shouldComplete, currentStepValue, velocity);
84 };
85 return SwipeBackGesture;
86}(SlideEdgeGesture));
87export { SwipeBackGesture };
88function SwipeBackGesture_tsickle_Closure_declarations() {
89 /** @type {?} */
90 SwipeBackGesture.prototype._nav;
91}
92//# sourceMappingURL=swipe-back.js.map
\No newline at end of file