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 { GESTURE_MENU_SWIPE, GESTURE_PRIORITY_MENU_SWIPE } from '../../gestures/gesture-controller';
|
12 | import { SlideEdgeGesture } from '../../gestures/slide-edge-gesture';
|
13 |
|
14 |
|
15 |
|
16 | var MenuContentGesture = (function (_super) {
|
17 | __extends(MenuContentGesture, _super);
|
18 | function MenuContentGesture(plt, menu, gestureCtrl, domCtrl) {
|
19 | var _this = _super.call(this, plt, plt.doc().body, {
|
20 | direction: 'x',
|
21 | edge: menu.side,
|
22 | threshold: 5,
|
23 | maxEdgeStart: menu.maxEdgeStart || 50,
|
24 | zone: false,
|
25 | passive: true,
|
26 | domController: domCtrl,
|
27 | gesture: gestureCtrl.createGesture({
|
28 | name: GESTURE_MENU_SWIPE,
|
29 | priority: GESTURE_PRIORITY_MENU_SWIPE,
|
30 | disableScroll: true
|
31 | })
|
32 | }) || this;
|
33 | _this.menu = menu;
|
34 | return _this;
|
35 | }
|
36 | MenuContentGesture.prototype.canStart = function (ev) {
|
37 | var menu = this.menu;
|
38 | if (!menu.canSwipe()) {
|
39 | return false;
|
40 | }
|
41 | if (menu.isOpen) {
|
42 | return true;
|
43 | }
|
44 | else if (menu.getMenuController().getOpen()) {
|
45 | return false;
|
46 | }
|
47 | return _super.prototype.canStart.call(this, ev);
|
48 | };
|
49 |
|
50 | MenuContentGesture.prototype.onSlideBeforeStart = function () {
|
51 | (void 0) ;
|
52 | this.menu._swipeBeforeStart();
|
53 | };
|
54 | MenuContentGesture.prototype.onSlideStart = function () {
|
55 | (void 0) ;
|
56 | this.menu._swipeStart();
|
57 | };
|
58 | MenuContentGesture.prototype.onSlide = function (slide) {
|
59 | var z = (this.menu.isRightSide !== this.plt.isRTL ? slide.min : slide.max);
|
60 | var stepValue = (slide.distance / z);
|
61 | this.menu._swipeProgress(stepValue);
|
62 | };
|
63 | MenuContentGesture.prototype.onSlideEnd = function (slide) {
|
64 | var z = (this.menu.isRightSide !== this.plt.isRTL ? slide.min : slide.max);
|
65 | var currentStepValue = (slide.distance / z);
|
66 | var velocity = slide.velocity;
|
67 | z = Math.abs(z * 0.5);
|
68 | var shouldCompleteRight = (velocity >= 0)
|
69 | && (velocity > 0.2 || slide.delta > z);
|
70 | var shouldCompleteLeft = (velocity <= 0)
|
71 | && (velocity < -0.2 || slide.delta < -z);
|
72 | (void 0) ;
|
73 | this.menu._swipeEnd(shouldCompleteLeft, shouldCompleteRight, currentStepValue, velocity);
|
74 | };
|
75 | MenuContentGesture.prototype.getElementStartPos = function (slide) {
|
76 | var menu = this.menu;
|
77 | if (menu.isRightSide !== this.plt.isRTL) {
|
78 | return menu.isOpen ? slide.min : slide.max;
|
79 | }
|
80 |
|
81 | return menu.isOpen ? slide.max : slide.min;
|
82 | };
|
83 | MenuContentGesture.prototype.getSlideBoundaries = function () {
|
84 | var menu = this.menu;
|
85 | if (menu.isRightSide !== this.plt.isRTL) {
|
86 | return {
|
87 | min: -menu.width(),
|
88 | max: 0
|
89 | };
|
90 | }
|
91 |
|
92 | return {
|
93 | min: 0,
|
94 | max: menu.width()
|
95 | };
|
96 | };
|
97 | return MenuContentGesture;
|
98 | }(SlideEdgeGesture));
|
99 | export { MenuContentGesture };
|
100 |
|
\ | No newline at end of file |