a zip code crypto-currency system good for red ONLY

item-sliding-gesture.js 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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/pan-gesture", "../../util/dom"], 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 pan_gesture_1 = require("../../gestures/pan-gesture");
  24. var dom_1 = require("../../util/dom");
  25. /**
  26. * @hidden
  27. */
  28. var ItemSlidingGesture = (function (_super) {
  29. __extends(ItemSlidingGesture, _super);
  30. function ItemSlidingGesture(plt, list, gestureCtrl, domCtrl) {
  31. var _this = _super.call(this, plt, list.getNativeElement(), {
  32. maxAngle: 20,
  33. threshold: 5,
  34. zone: false,
  35. domController: domCtrl,
  36. gesture: gestureCtrl.createGesture({
  37. name: gesture_controller_1.GESTURE_ITEM_SWIPE,
  38. priority: gesture_controller_1.GESTURE_PRIORITY_SLIDING_ITEM,
  39. disableScroll: true
  40. })
  41. }) || this;
  42. _this.list = list;
  43. _this.preSelectedContainer = null;
  44. _this.selectedContainer = null;
  45. _this.openContainer = null;
  46. return _this;
  47. }
  48. ItemSlidingGesture.prototype.canStart = function (ev) {
  49. if (this.selectedContainer) {
  50. return false;
  51. }
  52. // Get swiped sliding container
  53. var container = getContainer(ev);
  54. if (!container) {
  55. this.closeOpened();
  56. return false;
  57. }
  58. // Close open container if it is not the selected one.
  59. if (container !== this.openContainer) {
  60. this.closeOpened();
  61. }
  62. var coord = dom_1.pointerCoord(ev);
  63. this.preSelectedContainer = container;
  64. this.firstCoordX = coord.x;
  65. this.firstTimestamp = Date.now();
  66. return true;
  67. };
  68. ItemSlidingGesture.prototype.onDragStart = function (ev) {
  69. ev.preventDefault();
  70. var coord = dom_1.pointerCoord(ev);
  71. this.selectedContainer = this.openContainer = this.preSelectedContainer;
  72. this.selectedContainer.startSliding(coord.x);
  73. };
  74. ItemSlidingGesture.prototype.onDragMove = function (ev) {
  75. ev.preventDefault();
  76. this.selectedContainer.moveSliding(dom_1.pointerCoord(ev).x);
  77. };
  78. ItemSlidingGesture.prototype.onDragEnd = function (ev) {
  79. ev.preventDefault();
  80. var coordX = dom_1.pointerCoord(ev).x;
  81. var deltaX = (coordX - this.firstCoordX);
  82. var deltaT = (Date.now() - this.firstTimestamp);
  83. this.selectedContainer.endSliding(deltaX / deltaT);
  84. this.selectedContainer = null;
  85. this.preSelectedContainer = null;
  86. };
  87. ItemSlidingGesture.prototype.notCaptured = function (ev) {
  88. if (!clickedOptionButton(ev)) {
  89. this.closeOpened();
  90. }
  91. };
  92. ItemSlidingGesture.prototype.closeOpened = function () {
  93. this.selectedContainer = null;
  94. if (this.openContainer) {
  95. this.openContainer.close();
  96. this.openContainer = null;
  97. return true;
  98. }
  99. return false;
  100. };
  101. ItemSlidingGesture.prototype.destroy = function () {
  102. _super.prototype.destroy.call(this);
  103. this.closeOpened();
  104. this.list = null;
  105. this.preSelectedContainer = null;
  106. this.selectedContainer = null;
  107. this.openContainer = null;
  108. };
  109. return ItemSlidingGesture;
  110. }(pan_gesture_1.PanGesture));
  111. exports.ItemSlidingGesture = ItemSlidingGesture;
  112. function getContainer(ev) {
  113. var ele = ev.target.closest('ion-item-sliding');
  114. if (ele) {
  115. return ele['$ionComponent'];
  116. }
  117. return null;
  118. }
  119. function clickedOptionButton(ev) {
  120. var ele = ev.target.closest('ion-item-options>button');
  121. return !!ele;
  122. }
  123. });
  124. //# sourceMappingURL=item-sliding-gesture.js.map