UNPKG

3.31 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 { SlideGesture } from './slide-gesture';
12import { defaults } from '../util/util';
13import { pointerCoord } from '../util/dom';
14/**
15 * @hidden
16 */
17var SlideEdgeGesture = (function (_super) {
18 __extends(SlideEdgeGesture, _super);
19 /**
20 * @param {?} plt
21 * @param {?} element
22 * @param {?=} opts
23 */
24 function SlideEdgeGesture(plt, element, opts) {
25 if (opts === void 0) { opts = {}; }
26 var _this = this;
27 defaults(opts, {
28 edge: 'start',
29 maxEdgeStart: 50
30 });
31 _this = _super.call(this, plt, element, opts) || this;
32 // Can check corners through use of eg 'left top'
33 _this.setEdges(opts.edge);
34 _this.maxEdgeStart = opts.maxEdgeStart;
35 return _this;
36 }
37 /**
38 * @param {?} edges
39 * @return {?}
40 */
41 SlideEdgeGesture.prototype.setEdges = function (edges) {
42 var /** @type {?} */ isRTL = this.plt.isRTL;
43 this.edges = edges.split(' ').map(function (value) {
44 switch (value) {
45 case 'start': return isRTL ? 'right' : 'left';
46 case 'end': return isRTL ? 'left' : 'right';
47 default: return value;
48 }
49 });
50 };
51 /**
52 * @param {?} ev
53 * @return {?}
54 */
55 SlideEdgeGesture.prototype.canStart = function (ev) {
56 var _this = this;
57 var /** @type {?} */ coord = pointerCoord(ev);
58 this._d = this.getContainerDimensions();
59 return this.edges.every(function (edge) { return _this._checkEdge(edge, coord); });
60 };
61 /**
62 * @return {?}
63 */
64 SlideEdgeGesture.prototype.getContainerDimensions = function () {
65 var /** @type {?} */ plt = this.plt;
66 return {
67 left: 0,
68 top: 0,
69 width: plt.width(),
70 height: plt.height()
71 };
72 };
73 /**
74 * @param {?} edge
75 * @param {?} pos
76 * @return {?}
77 */
78 SlideEdgeGesture.prototype._checkEdge = function (edge, pos) {
79 var /** @type {?} */ data = this._d;
80 var /** @type {?} */ maxEdgeStart = this.maxEdgeStart;
81 switch (edge) {
82 case 'left': return pos.x <= data.left + maxEdgeStart;
83 case 'right': return pos.x >= data.width - maxEdgeStart;
84 case 'top': return pos.y <= data.top + maxEdgeStart;
85 case 'bottom': return pos.y >= data.height - maxEdgeStart;
86 }
87 return false;
88 };
89 return SlideEdgeGesture;
90}(SlideGesture));
91export { SlideEdgeGesture };
92function SlideEdgeGesture_tsickle_Closure_declarations() {
93 /** @type {?} */
94 SlideEdgeGesture.prototype.edges;
95 /** @type {?} */
96 SlideEdgeGesture.prototype.maxEdgeStart;
97 /** @type {?} */
98 SlideEdgeGesture.prototype._d;
99}
100//# sourceMappingURL=slide-edge-gesture.js.map
\No newline at end of file