a zip code crypto-currency system good for red ONLY

popover-transitions.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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 { Animation } from '../../animations/animation';
  12. import { PageTransition } from '../../transitions/page-transition';
  13. /**
  14. * Animations for popover
  15. */
  16. var PopoverTransition = (function (_super) {
  17. __extends(PopoverTransition, _super);
  18. function PopoverTransition() {
  19. return _super !== null && _super.apply(this, arguments) || this;
  20. }
  21. PopoverTransition.prototype.mdPositionView = function (nativeEle, ev) {
  22. var originY = 'top';
  23. var originX = 'left';
  24. var popoverWrapperEle = nativeEle.querySelector('.popover-wrapper');
  25. // Popover content width and height
  26. var popoverEle = nativeEle.querySelector('.popover-content');
  27. var popoverDim = popoverEle.getBoundingClientRect();
  28. var popoverWidth = popoverDim.width;
  29. var popoverHeight = popoverDim.height;
  30. // Window body width and height
  31. var bodyWidth = this.plt.width();
  32. var bodyHeight = this.plt.height();
  33. // If ev was passed, use that for target element
  34. var targetDim = ev && ev.target && ev.target.getBoundingClientRect();
  35. var targetTop = (targetDim && 'top' in targetDim) ? targetDim.top : (bodyHeight / 2) - (popoverHeight / 2);
  36. var targetLeft = (targetDim && 'left' in targetDim) ? targetDim.left : (bodyWidth / 2) - (popoverWidth / 2);
  37. var targetHeight = targetDim && targetDim.height || 0;
  38. var popoverCSS = {
  39. top: targetTop,
  40. left: targetLeft
  41. };
  42. // If the popover left is less than the padding it is off screen
  43. // to the left so adjust it, else if the width of the popover
  44. // exceeds the body width it is off screen to the right so adjust
  45. if (popoverCSS.left < POPOVER_MD_BODY_PADDING) {
  46. popoverCSS.left = POPOVER_MD_BODY_PADDING;
  47. }
  48. else if (popoverWidth + POPOVER_MD_BODY_PADDING + popoverCSS.left > bodyWidth) {
  49. popoverCSS.left = bodyWidth - popoverWidth - POPOVER_MD_BODY_PADDING;
  50. originX = 'right';
  51. }
  52. // If the popover when popped down stretches past bottom of screen,
  53. // make it pop up if there's room above
  54. if (targetTop + targetHeight + popoverHeight > bodyHeight && targetTop - popoverHeight > 0) {
  55. popoverCSS.top = targetTop - popoverHeight;
  56. nativeEle.className = nativeEle.className + ' popover-bottom';
  57. originY = 'bottom';
  58. // If there isn't room for it to pop up above the target cut it off
  59. }
  60. else if (targetTop + targetHeight + popoverHeight > bodyHeight) {
  61. popoverEle.style.bottom = POPOVER_MD_BODY_PADDING + 'px';
  62. }
  63. popoverEle.style.top = popoverCSS.top + 'px';
  64. popoverEle.style.left = popoverCSS.left + 'px';
  65. popoverEle.style[this.plt.Css.transformOrigin] = originY + ' ' + originX;
  66. // Since the transition starts before styling is done we
  67. // want to wait for the styles to apply before showing the wrapper
  68. popoverWrapperEle.style.opacity = '1';
  69. };
  70. PopoverTransition.prototype.iosPositionView = function (nativeEle, ev) {
  71. var originY = 'top';
  72. var originX = 'left';
  73. var popoverWrapperEle = nativeEle.querySelector('.popover-wrapper');
  74. // Popover content width and height
  75. var popoverEle = nativeEle.querySelector('.popover-content');
  76. var popoverDim = popoverEle.getBoundingClientRect();
  77. var popoverWidth = popoverDim.width;
  78. var popoverHeight = popoverDim.height;
  79. // Window body width and height
  80. var bodyWidth = this.plt.width();
  81. var bodyHeight = this.plt.height();
  82. // If ev was passed, use that for target element
  83. var targetDim = ev && ev.target && ev.target.getBoundingClientRect();
  84. var targetTop = (targetDim && 'top' in targetDim) ? targetDim.top : (bodyHeight / 2) - (popoverHeight / 2);
  85. var targetLeft = (targetDim && 'left' in targetDim) ? targetDim.left : (bodyWidth / 2);
  86. var targetWidth = targetDim && targetDim.width || 0;
  87. var targetHeight = targetDim && targetDim.height || 0;
  88. // The arrow that shows above the popover on iOS
  89. var arrowEle = nativeEle.querySelector('.popover-arrow');
  90. var arrowDim = arrowEle.getBoundingClientRect();
  91. var arrowWidth = arrowDim.width;
  92. var arrowHeight = arrowDim.height;
  93. // If no ev was passed, hide the arrow
  94. if (!targetDim) {
  95. arrowEle.style.display = 'none';
  96. }
  97. var arrowCSS = {
  98. top: targetTop + targetHeight,
  99. left: targetLeft + (targetWidth / 2) - (arrowWidth / 2)
  100. };
  101. var popoverCSS = {
  102. top: targetTop + targetHeight + (arrowHeight - 1),
  103. left: targetLeft + (targetWidth / 2) - (popoverWidth / 2)
  104. };
  105. // If the popover left is less than the padding it is off screen
  106. // to the left so adjust it, else if the width of the popover
  107. // exceeds the body width it is off screen to the right so adjust
  108. //
  109. var checkSafeAreaLeft = false;
  110. var checkSafeAreaRight = false;
  111. // If the popover left is less than the padding it is off screen
  112. // to the left so adjust it, else if the width of the popover
  113. // exceeds the body width it is off screen to the right so adjust
  114. // 25 is a random/arbitrary number. It seems to work fine for ios11
  115. // and iPhoneX. Is it perfect? No. Does it work? Yes.
  116. if (popoverCSS.left < (POPOVER_IOS_BODY_PADDING + 25)) {
  117. checkSafeAreaLeft = true;
  118. popoverCSS.left = POPOVER_IOS_BODY_PADDING;
  119. }
  120. else if ((popoverWidth + POPOVER_IOS_BODY_PADDING + popoverCSS.left + 25) > bodyWidth) {
  121. // Ok, so we're on the right side of the screen,
  122. // but now we need to make sure we're still a bit further right
  123. // cus....notchurally... Again, 25 is random. It works tho
  124. checkSafeAreaRight = true;
  125. popoverCSS.left = bodyWidth - popoverWidth - POPOVER_IOS_BODY_PADDING;
  126. originX = 'right';
  127. }
  128. // make it pop up if there's room above
  129. if (targetTop + targetHeight + popoverHeight > bodyHeight && targetTop - popoverHeight > 0) {
  130. arrowCSS.top = targetTop - (arrowHeight + 1);
  131. popoverCSS.top = targetTop - popoverHeight - (arrowHeight - 1);
  132. nativeEle.className = nativeEle.className + ' popover-bottom';
  133. originY = 'bottom';
  134. // If there isn't room for it to pop up above the target cut it off
  135. }
  136. else if (targetTop + targetHeight + popoverHeight > bodyHeight) {
  137. popoverEle.style.bottom = POPOVER_IOS_BODY_PADDING + '%';
  138. }
  139. arrowEle.style.top = arrowCSS.top + 'px';
  140. arrowEle.style.left = arrowCSS.left + 'px';
  141. popoverEle.style.top = popoverCSS.top + 'px';
  142. popoverEle.style.left = popoverCSS.left + 'px';
  143. if (checkSafeAreaLeft) {
  144. if (CSS.supports('left', 'constant(safe-area-inset-left)')) {
  145. popoverEle.style.left = "calc(" + popoverCSS.left + "px + constant(safe-area-inset-left)";
  146. }
  147. else if (CSS.supports('left', 'env(safe-area-inset-left)')) {
  148. popoverEle.style.left = "calc(" + popoverCSS.left + "px + env(safe-area-inset-left)";
  149. }
  150. }
  151. if (checkSafeAreaRight) {
  152. if (CSS.supports('right', 'constant(safe-area-inset-right)')) {
  153. popoverEle.style.left = "calc(" + popoverCSS.left + "px - constant(safe-area-inset-right)";
  154. }
  155. else if (CSS.supports('right', 'env(safe-area-inset-right)')) {
  156. popoverEle.style.left = "calc(" + popoverCSS.left + "px - env(safe-area-inset-right)";
  157. }
  158. }
  159. popoverEle.style[this.plt.Css.transformOrigin] = originY + ' ' + originX;
  160. // Since the transition starts before styling is done we
  161. // want to wait for the styles to apply before showing the wrapper
  162. popoverWrapperEle.style.opacity = '1';
  163. };
  164. return PopoverTransition;
  165. }(PageTransition));
  166. export { PopoverTransition };
  167. var PopoverPopIn = (function (_super) {
  168. __extends(PopoverPopIn, _super);
  169. function PopoverPopIn() {
  170. return _super !== null && _super.apply(this, arguments) || this;
  171. }
  172. PopoverPopIn.prototype.init = function () {
  173. var ele = this.enteringView.pageRef().nativeElement;
  174. var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
  175. var wrapper = new Animation(this.plt, ele.querySelector('.popover-wrapper'));
  176. wrapper.fromTo('opacity', 0.01, 1);
  177. backdrop.fromTo('opacity', 0.01, 0.08);
  178. this
  179. .easing('ease')
  180. .duration(100)
  181. .add(backdrop)
  182. .add(wrapper);
  183. };
  184. PopoverPopIn.prototype.play = function () {
  185. var _this = this;
  186. this.plt.raf(function () {
  187. _this.iosPositionView(_this.enteringView.pageRef().nativeElement, _this.opts.ev);
  188. _super.prototype.play.call(_this);
  189. });
  190. };
  191. return PopoverPopIn;
  192. }(PopoverTransition));
  193. export { PopoverPopIn };
  194. var PopoverPopOut = (function (_super) {
  195. __extends(PopoverPopOut, _super);
  196. function PopoverPopOut() {
  197. return _super !== null && _super.apply(this, arguments) || this;
  198. }
  199. PopoverPopOut.prototype.init = function () {
  200. var ele = this.leavingView.pageRef().nativeElement;
  201. var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
  202. var wrapper = new Animation(this.plt, ele.querySelector('.popover-wrapper'));
  203. wrapper.fromTo('opacity', 0.99, 0);
  204. backdrop.fromTo('opacity', 0.08, 0);
  205. this
  206. .easing('ease')
  207. .duration(500)
  208. .add(backdrop)
  209. .add(wrapper);
  210. };
  211. return PopoverPopOut;
  212. }(PopoverTransition));
  213. export { PopoverPopOut };
  214. var PopoverMdPopIn = (function (_super) {
  215. __extends(PopoverMdPopIn, _super);
  216. function PopoverMdPopIn() {
  217. return _super !== null && _super.apply(this, arguments) || this;
  218. }
  219. PopoverMdPopIn.prototype.init = function () {
  220. var ele = this.enteringView.pageRef().nativeElement;
  221. var content = new Animation(this.plt, ele.querySelector('.popover-content'));
  222. var viewport = new Animation(this.plt, ele.querySelector('.popover-viewport'));
  223. content.fromTo('scale', 0.001, 1);
  224. viewport.fromTo('opacity', 0.01, 1);
  225. this
  226. .easing('cubic-bezier(0.36,0.66,0.04,1)')
  227. .duration(300)
  228. .add(content)
  229. .add(viewport);
  230. };
  231. PopoverMdPopIn.prototype.play = function () {
  232. var _this = this;
  233. this.plt.raf(function () {
  234. _this.mdPositionView(_this.enteringView.pageRef().nativeElement, _this.opts.ev);
  235. _super.prototype.play.call(_this);
  236. });
  237. };
  238. return PopoverMdPopIn;
  239. }(PopoverTransition));
  240. export { PopoverMdPopIn };
  241. var PopoverMdPopOut = (function (_super) {
  242. __extends(PopoverMdPopOut, _super);
  243. function PopoverMdPopOut() {
  244. return _super !== null && _super.apply(this, arguments) || this;
  245. }
  246. PopoverMdPopOut.prototype.init = function () {
  247. var ele = this.leavingView.pageRef().nativeElement;
  248. var wrapper = new Animation(this.plt, ele.querySelector('.popover-wrapper'));
  249. wrapper.fromTo('opacity', 0.99, 0);
  250. this
  251. .easing('ease')
  252. .duration(500)
  253. .fromTo('opacity', 0.01, 1)
  254. .add(wrapper);
  255. };
  256. return PopoverMdPopOut;
  257. }(PopoverTransition));
  258. export { PopoverMdPopOut };
  259. var POPOVER_IOS_BODY_PADDING = 2;
  260. var POPOVER_MD_BODY_PADDING = 12;
  261. //# sourceMappingURL=popover-transitions.js.map