a zip code crypto-currency system good for red ONLY

slide-edge-gesture.js 3.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. (function (factory) {
  12. if (typeof module === "object" && typeof module.exports === "object") {
  13. var v = factory(require, exports);
  14. if (v !== undefined) module.exports = v;
  15. }
  16. else if (typeof define === "function" && define.amd) {
  17. define(["require", "exports", "./slide-gesture", "../util/util", "../util/dom"], factory);
  18. }
  19. })(function (require, exports) {
  20. "use strict";
  21. Object.defineProperty(exports, "__esModule", { value: true });
  22. var slide_gesture_1 = require("./slide-gesture");
  23. var util_1 = require("../util/util");
  24. var dom_1 = require("../util/dom");
  25. /**
  26. * @hidden
  27. */
  28. var SlideEdgeGesture = (function (_super) {
  29. __extends(SlideEdgeGesture, _super);
  30. function SlideEdgeGesture(plt, element, opts) {
  31. if (opts === void 0) { opts = {}; }
  32. var _this = this;
  33. util_1.defaults(opts, {
  34. edge: 'start',
  35. maxEdgeStart: 50
  36. });
  37. _this = _super.call(this, plt, element, opts) || this;
  38. // Can check corners through use of eg 'left top'
  39. _this.setEdges(opts.edge);
  40. _this.maxEdgeStart = opts.maxEdgeStart;
  41. return _this;
  42. }
  43. SlideEdgeGesture.prototype.setEdges = function (edges) {
  44. var isRTL = this.plt.isRTL;
  45. this.edges = edges.split(' ').map(function (value) {
  46. switch (value) {
  47. case 'start': return isRTL ? 'right' : 'left';
  48. case 'end': return isRTL ? 'left' : 'right';
  49. default: return value;
  50. }
  51. });
  52. };
  53. SlideEdgeGesture.prototype.canStart = function (ev) {
  54. var _this = this;
  55. var coord = dom_1.pointerCoord(ev);
  56. this._d = this.getContainerDimensions();
  57. return this.edges.every(function (edge) { return _this._checkEdge(edge, coord); });
  58. };
  59. SlideEdgeGesture.prototype.getContainerDimensions = function () {
  60. var plt = this.plt;
  61. return {
  62. left: 0,
  63. top: 0,
  64. width: plt.width(),
  65. height: plt.height()
  66. };
  67. };
  68. SlideEdgeGesture.prototype._checkEdge = function (edge, pos) {
  69. var data = this._d;
  70. var maxEdgeStart = this.maxEdgeStart;
  71. switch (edge) {
  72. case 'left': return pos.x <= data.left + maxEdgeStart;
  73. case 'right': return pos.x >= data.width - maxEdgeStart;
  74. case 'top': return pos.y <= data.top + maxEdgeStart;
  75. case 'bottom': return pos.y >= data.height - maxEdgeStart;
  76. }
  77. return false;
  78. };
  79. return SlideEdgeGesture;
  80. }(slide_gesture_1.SlideGesture));
  81. exports.SlideEdgeGesture = SlideEdgeGesture;
  82. });
  83. //# sourceMappingURL=slide-edge-gesture.js.map