a zip code crypto-currency system good for red ONLY

menu-gestures.js 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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", "../../gestures/gesture-controller", "../../gestures/slide-edge-gesture"], factory);
  18. }
  19. })(function (require, exports) {
  20. "use strict";
  21. Object.defineProperty(exports, "__esModule", { value: true });
  22. var gesture_controller_1 = require("../../gestures/gesture-controller");
  23. var slide_edge_gesture_1 = require("../../gestures/slide-edge-gesture");
  24. /**
  25. * Gesture attached to the content which the menu is assigned to
  26. */
  27. var MenuContentGesture = (function (_super) {
  28. __extends(MenuContentGesture, _super);
  29. function MenuContentGesture(plt, menu, gestureCtrl, domCtrl) {
  30. var _this = _super.call(this, plt, plt.doc().body, {
  31. direction: 'x',
  32. edge: menu.side,
  33. threshold: 5,
  34. maxEdgeStart: menu.maxEdgeStart || 50,
  35. zone: false,
  36. passive: true,
  37. domController: domCtrl,
  38. gesture: gestureCtrl.createGesture({
  39. name: gesture_controller_1.GESTURE_MENU_SWIPE,
  40. priority: gesture_controller_1.GESTURE_PRIORITY_MENU_SWIPE,
  41. disableScroll: true
  42. })
  43. }) || this;
  44. _this.menu = menu;
  45. return _this;
  46. }
  47. MenuContentGesture.prototype.canStart = function (ev) {
  48. var menu = this.menu;
  49. if (!menu.canSwipe()) {
  50. return false;
  51. }
  52. if (menu.isOpen) {
  53. return true;
  54. }
  55. else if (menu.getMenuController().getOpen()) {
  56. return false;
  57. }
  58. return _super.prototype.canStart.call(this, ev);
  59. };
  60. // Set CSS, then wait one frame for it to apply before sliding starts
  61. MenuContentGesture.prototype.onSlideBeforeStart = function () {
  62. (void 0) /* console.debug */;
  63. this.menu._swipeBeforeStart();
  64. };
  65. MenuContentGesture.prototype.onSlideStart = function () {
  66. (void 0) /* console.debug */;
  67. this.menu._swipeStart();
  68. };
  69. MenuContentGesture.prototype.onSlide = function (slide) {
  70. var z = (this.menu.isRightSide !== this.plt.isRTL ? slide.min : slide.max);
  71. var stepValue = (slide.distance / z);
  72. this.menu._swipeProgress(stepValue);
  73. };
  74. MenuContentGesture.prototype.onSlideEnd = function (slide) {
  75. var z = (this.menu.isRightSide !== this.plt.isRTL ? slide.min : slide.max);
  76. var currentStepValue = (slide.distance / z);
  77. var velocity = slide.velocity;
  78. z = Math.abs(z * 0.5);
  79. var shouldCompleteRight = (velocity >= 0)
  80. && (velocity > 0.2 || slide.delta > z);
  81. var shouldCompleteLeft = (velocity <= 0)
  82. && (velocity < -0.2 || slide.delta < -z);
  83. (void 0) /* console.debug */;
  84. this.menu._swipeEnd(shouldCompleteLeft, shouldCompleteRight, currentStepValue, velocity);
  85. };
  86. MenuContentGesture.prototype.getElementStartPos = function (slide) {
  87. var menu = this.menu;
  88. if (menu.isRightSide !== this.plt.isRTL) {
  89. return menu.isOpen ? slide.min : slide.max;
  90. }
  91. // left menu
  92. return menu.isOpen ? slide.max : slide.min;
  93. };
  94. MenuContentGesture.prototype.getSlideBoundaries = function () {
  95. var menu = this.menu;
  96. if (menu.isRightSide !== this.plt.isRTL) {
  97. return {
  98. min: -menu.width(),
  99. max: 0
  100. };
  101. }
  102. // left menu
  103. return {
  104. min: 0,
  105. max: menu.width()
  106. };
  107. };
  108. return MenuContentGesture;
  109. }(slide_edge_gesture_1.SlideEdgeGesture));
  110. exports.MenuContentGesture = MenuContentGesture;
  111. });
  112. //# sourceMappingURL=menu-gestures.js.map