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 | function SlideEdgeGesture(plt, element, opts) {
|
20 | if (opts === void 0) { opts = {}; }
|
21 | var _this = this;
|
22 | defaults(opts, {
|
23 | edge: 'start',
|
24 | maxEdgeStart: 50
|
25 | });
|
26 | _this = _super.call(this, plt, element, opts) || this;
|
27 |
|
28 | _this.setEdges(opts.edge);
|
29 | _this.maxEdgeStart = opts.maxEdgeStart;
|
30 | return _this;
|
31 | }
|
32 | SlideEdgeGesture.prototype.setEdges = function (edges) {
|
33 | var isRTL = this.plt.isRTL;
|
34 | this.edges = edges.split(' ').map(function (value) {
|
35 | switch (value) {
|
36 | case 'start': return isRTL ? 'right' : 'left';
|
37 | case 'end': return isRTL ? 'left' : 'right';
|
38 | default: return value;
|
39 | }
|
40 | });
|
41 | };
|
42 | SlideEdgeGesture.prototype.canStart = function (ev) {
|
43 | var _this = this;
|
44 | var coord = pointerCoord(ev);
|
45 | this._d = this.getContainerDimensions();
|
46 | return this.edges.every(function (edge) { return _this._checkEdge(edge, coord); });
|
47 | };
|
48 | SlideEdgeGesture.prototype.getContainerDimensions = function () {
|
49 | var plt = this.plt;
|
50 | return {
|
51 | left: 0,
|
52 | top: 0,
|
53 | width: plt.width(),
|
54 | height: plt.height()
|
55 | };
|
56 | };
|
57 | SlideEdgeGesture.prototype._checkEdge = function (edge, pos) {
|
58 | var data = this._d;
|
59 | var maxEdgeStart = this.maxEdgeStart;
|
60 | switch (edge) {
|
61 | case 'left': return pos.x <= data.left + maxEdgeStart;
|
62 | case 'right': return pos.x >= data.width - maxEdgeStart;
|
63 | case 'top': return pos.y <= data.top + maxEdgeStart;
|
64 | case 'bottom': return pos.y >= data.height - maxEdgeStart;
|
65 | }
|
66 | return false;
|
67 | };
|
68 | return SlideEdgeGesture;
|
69 | }(SlideGesture));
|
70 | export { SlideEdgeGesture };
|
71 |
|
\ | No newline at end of file |