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 { SlideGesture } from './slide-gesture';
|
12 | import { defaults } from '../util/util';
|
13 | import { pointerCoord } from '../util/dom';
|
14 |
|
15 |
|
16 |
|
17 | var SlideEdgeGesture = (function (_super) {
|
18 | __extends(SlideEdgeGesture, _super);
|
19 | |
20 |
|
21 |
|
22 |
|
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 |
|
33 | _this.setEdges(opts.edge);
|
34 | _this.maxEdgeStart = opts.maxEdgeStart;
|
35 | return _this;
|
36 | }
|
37 | |
38 |
|
39 |
|
40 |
|
41 | SlideEdgeGesture.prototype.setEdges = function (edges) {
|
42 | var 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 |
|
53 |
|
54 |
|
55 | SlideEdgeGesture.prototype.canStart = function (ev) {
|
56 | var _this = this;
|
57 | var coord = pointerCoord(ev);
|
58 | this._d = this.getContainerDimensions();
|
59 | return this.edges.every(function (edge) { return _this._checkEdge(edge, coord); });
|
60 | };
|
61 | |
62 |
|
63 |
|
64 | SlideEdgeGesture.prototype.getContainerDimensions = function () {
|
65 | var plt = this.plt;
|
66 | return {
|
67 | left: 0,
|
68 | top: 0,
|
69 | width: plt.width(),
|
70 | height: plt.height()
|
71 | };
|
72 | };
|
73 | |
74 |
|
75 |
|
76 |
|
77 |
|
78 | SlideEdgeGesture.prototype._checkEdge = function (edge, pos) {
|
79 | var data = this._d;
|
80 | var 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));
|
91 | export { SlideEdgeGesture };
|
92 | function SlideEdgeGesture_tsickle_Closure_declarations() {
|
93 |
|
94 | SlideEdgeGesture.prototype.edges;
|
95 |
|
96 | SlideEdgeGesture.prototype.maxEdgeStart;
|
97 |
|
98 | SlideEdgeGesture.prototype._d;
|
99 | }
|
100 |
|
\ | No newline at end of file |