a zip code crypto-currency system good for red ONLY

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959
  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", "@angular/core", "../app/app", "../../config/config", "../../platform/dom-controller", "../ion", "../../navigation/nav-util", "../../util/util", "../../platform/keyboard", "../../navigation/nav-controller", "../../platform/platform", "../../util/scroll-view", "../../navigation/view-controller"], factory);
  18. }
  19. })(function (require, exports) {
  20. "use strict";
  21. Object.defineProperty(exports, "__esModule", { value: true });
  22. var core_1 = require("@angular/core");
  23. var app_1 = require("../app/app");
  24. var config_1 = require("../../config/config");
  25. var dom_controller_1 = require("../../platform/dom-controller");
  26. var ion_1 = require("../ion");
  27. var nav_util_1 = require("../../navigation/nav-util");
  28. var util_1 = require("../../util/util");
  29. var keyboard_1 = require("../../platform/keyboard");
  30. var nav_controller_1 = require("../../navigation/nav-controller");
  31. var platform_1 = require("../../platform/platform");
  32. var scroll_view_1 = require("../../util/scroll-view");
  33. var view_controller_1 = require("../../navigation/view-controller");
  34. var EventEmitterProxy = (function (_super) {
  35. __extends(EventEmitterProxy, _super);
  36. function EventEmitterProxy() {
  37. return _super !== null && _super.apply(this, arguments) || this;
  38. }
  39. EventEmitterProxy.prototype.subscribe = function (generatorOrNext, error, complete) {
  40. this.onSubscribe();
  41. return _super.prototype.subscribe.call(this, generatorOrNext, error, complete);
  42. };
  43. return EventEmitterProxy;
  44. }(core_1.EventEmitter));
  45. exports.EventEmitterProxy = EventEmitterProxy;
  46. /**
  47. * @name Content
  48. * @description
  49. * The Content component provides an easy to use content area with
  50. * some useful methods to control the scrollable area. There should
  51. * only be one content in a single view component. If additional scrollable
  52. * elements are needed, use [ionScroll](../../scroll/Scroll).
  53. *
  54. *
  55. * The content area can also implement pull-to-refresh with the
  56. * [Refresher](../../refresher/Refresher) component.
  57. *
  58. * @usage
  59. * ```html
  60. * <ion-content>
  61. * Add your content here!
  62. * </ion-content>
  63. * ```
  64. *
  65. * To get a reference to the content component from a Page's logic,
  66. * you can use Angular's `@ViewChild` annotation:
  67. *
  68. * ```ts
  69. * import { Component, ViewChild } from '@angular/core';
  70. * import { Content } from 'ionic-angular';
  71. *
  72. * @Component({...})
  73. * export class MyPage{
  74. * @ViewChild(Content) content: Content;
  75. *
  76. * scrollToTop() {
  77. * this.content.scrollToTop();
  78. * }
  79. * }
  80. * ```
  81. *
  82. * @advanced
  83. *
  84. * ### Scroll Events
  85. *
  86. * Scroll events happen outside of Angular's Zones. This is for performance reasons. So
  87. * if you're trying to bind a value to any scroll event, it will need to be wrapped in
  88. * a `zone.run()`
  89. *
  90. * ```ts
  91. * import { Component, NgZone } from '@angular/core';
  92. * @Component({
  93. * template: `
  94. * <ion-header>
  95. * <ion-navbar>
  96. * <ion-title>{{scrollAmount}}</ion-title>
  97. * </ion-navbar>
  98. * </ion-header>
  99. * <ion-content (ionScroll)="scrollHandler($event)">
  100. * <p> Some realllllllly long content </p>
  101. * </ion-content>
  102. * `})
  103. * class E2EPage {
  104. * public scrollAmount = 0;
  105. * constructor( public zone: NgZone){}
  106. * scrollHandler(event) {
  107. * console.log(`ScrollEvent: ${event}`)
  108. * this.zone.run(()=>{
  109. * // since scrollAmount is data-binded,
  110. * // the update needs to happen in zone
  111. * this.scrollAmount++
  112. * })
  113. * }
  114. * }
  115. * ```
  116. *
  117. * This goes for any scroll event, not just `ionScroll`.
  118. *
  119. * ### Resizing the content
  120. *
  121. * If the height of `ion-header`, `ion-footer` or `ion-tabbar`
  122. * changes dynamically, `content.resize()` has to be called in order to update the
  123. * layout of `Content`.
  124. *
  125. *
  126. * ```ts
  127. * @Component({
  128. * template: `
  129. * <ion-header>
  130. * <ion-navbar>
  131. * <ion-title>Main Navbar</ion-title>
  132. * </ion-navbar>
  133. * <ion-toolbar *ngIf="showToolbar">
  134. * <ion-title>Dynamic Toolbar</ion-title>
  135. * </ion-toolbar>
  136. * </ion-header>
  137. * <ion-content>
  138. * <button ion-button (click)="toggleToolbar()">Toggle Toolbar</button>
  139. * </ion-content>
  140. * `})
  141. *
  142. * class E2EPage {
  143. * @ViewChild(Content) content: Content;
  144. * showToolbar: boolean = false;
  145. *
  146. * toggleToolbar() {
  147. * this.showToolbar = !this.showToolbar;
  148. * this.content.resize();
  149. * }
  150. * }
  151. * ```
  152. *
  153. *
  154. * Scroll to a specific position
  155. *
  156. * ```ts
  157. * import { Component, ViewChild } from '@angular/core';
  158. * import { Content } from 'ionic-angular';
  159. *
  160. * @Component({
  161. * template: `<ion-content>
  162. * <button ion-button (click)="scrollTo()">Down 500px</button>
  163. * </ion-content>`
  164. * )}
  165. * export class MyPage{
  166. * @ViewChild(Content) content: Content;
  167. *
  168. * scrollTo() {
  169. * // set the scrollLeft to 0px, and scrollTop to 500px
  170. * // the scroll duration should take 200ms
  171. * this.content.scrollTo(0, 500, 200);
  172. * }
  173. * }
  174. * ```
  175. *
  176. */
  177. var Content = (function (_super) {
  178. __extends(Content, _super);
  179. function Content(config, _plt, _dom, elementRef, renderer, _app, _keyboard, _zone, viewCtrl, navCtrl) {
  180. var _this = _super.call(this, config, elementRef, renderer, 'content') || this;
  181. _this._plt = _plt;
  182. _this._dom = _dom;
  183. _this._app = _app;
  184. _this._keyboard = _keyboard;
  185. _this._zone = _zone;
  186. /** @internal */
  187. _this._scrollPadding = 0;
  188. /** @internal */
  189. _this._inputPolling = false;
  190. /** @internal */
  191. _this._hasRefresher = false;
  192. /** @internal */
  193. _this._imgs = [];
  194. /** @internal */
  195. _this._scrollDownOnLoad = false;
  196. /**
  197. * @output {ScrollEvent} Emitted when the scrolling first starts.
  198. */
  199. _this.ionScrollStart = new EventEmitterProxy();
  200. /**
  201. * @output {ScrollEvent} Emitted on every scroll event.
  202. */
  203. _this.ionScroll = new EventEmitterProxy();
  204. /**
  205. * @output {ScrollEvent} Emitted when scrolling ends.
  206. */
  207. _this.ionScrollEnd = new EventEmitterProxy();
  208. var enableScrollListener = function () { return _this._scroll.enableEvents(); };
  209. _this.ionScroll.onSubscribe = enableScrollListener;
  210. _this.ionScrollStart.onSubscribe = enableScrollListener;
  211. _this.ionScrollEnd.onSubscribe = enableScrollListener;
  212. _this.statusbarPadding = config.getBoolean('statusbarPadding', false);
  213. _this._imgReqBfr = config.getNumber('imgRequestBuffer', 1400);
  214. _this._imgRndBfr = config.getNumber('imgRenderBuffer', 400);
  215. _this._imgVelMax = config.getNumber('imgVelocityMax', 3);
  216. _this._scroll = new scroll_view_1.ScrollView(_app, _plt, _dom);
  217. while (navCtrl) {
  218. if (nav_util_1.isTabs(navCtrl)) {
  219. _this._tabs = navCtrl;
  220. break;
  221. }
  222. navCtrl = navCtrl.parent;
  223. }
  224. if (viewCtrl) {
  225. _this._viewCtrl = viewCtrl;
  226. // content has a view controller
  227. viewCtrl._setIONContent(_this);
  228. viewCtrl._setIONContentRef(elementRef);
  229. _this._viewCtrlReadSub = viewCtrl.readReady.subscribe(function () {
  230. _this._viewCtrlReadSub.unsubscribe();
  231. _this._readDimensions();
  232. });
  233. _this._viewCtrlWriteSub = viewCtrl.writeReady.subscribe(function () {
  234. _this._viewCtrlWriteSub.unsubscribe();
  235. _this._writeDimensions();
  236. });
  237. }
  238. else {
  239. // content does not have a view controller
  240. _dom.read(_this._readDimensions.bind(_this));
  241. _dom.write(_this._writeDimensions.bind(_this));
  242. }
  243. return _this;
  244. }
  245. Object.defineProperty(Content.prototype, "contentHeight", {
  246. /**
  247. * Content height of the viewable area. This does not include content
  248. * which is outside the overflow area, or content area which is under
  249. * headers and footers. Read-only.
  250. *
  251. * @return {number}
  252. */
  253. get: function () {
  254. return this._scroll.ev.contentHeight;
  255. },
  256. enumerable: true,
  257. configurable: true
  258. });
  259. Object.defineProperty(Content.prototype, "contentWidth", {
  260. /**
  261. * Content width including content which is not visible on the screen
  262. * due to overflow. Read-only.
  263. *
  264. * @return {number}
  265. */
  266. get: function () {
  267. return this._scroll.ev.contentWidth;
  268. },
  269. enumerable: true,
  270. configurable: true
  271. });
  272. Object.defineProperty(Content.prototype, "scrollHeight", {
  273. /**
  274. * Content height including content which is not visible on the screen
  275. * due to overflow. Read-only.
  276. *
  277. * @return {number}
  278. */
  279. get: function () {
  280. return this._scroll.ev.scrollHeight;
  281. },
  282. enumerable: true,
  283. configurable: true
  284. });
  285. Object.defineProperty(Content.prototype, "scrollWidth", {
  286. /**
  287. * Content width including content which is not visible due to
  288. * overflow. Read-only.
  289. *
  290. * @return {number}
  291. */
  292. get: function () {
  293. return this._scroll.ev.scrollWidth;
  294. },
  295. enumerable: true,
  296. configurable: true
  297. });
  298. Object.defineProperty(Content.prototype, "scrollTop", {
  299. /**
  300. * The distance of the content's top to its topmost visible content.
  301. *
  302. * @return {number}
  303. */
  304. get: function () {
  305. return this._scroll.ev.scrollTop;
  306. },
  307. /**
  308. * @param {number} top
  309. */
  310. set: function (top) {
  311. this._scroll.setTop(top);
  312. },
  313. enumerable: true,
  314. configurable: true
  315. });
  316. Object.defineProperty(Content.prototype, "scrollLeft", {
  317. /**
  318. * The distance of the content's left to its leftmost visible content.
  319. *
  320. * @return {number}
  321. */
  322. get: function () {
  323. return this._scroll.ev.scrollLeft;
  324. },
  325. /**
  326. * @param {number} top
  327. */
  328. set: function (top) {
  329. this._scroll.setLeft(top);
  330. },
  331. enumerable: true,
  332. configurable: true
  333. });
  334. Object.defineProperty(Content.prototype, "isScrolling", {
  335. /**
  336. * If the content is actively scrolling or not.
  337. *
  338. * @return {boolean}
  339. */
  340. get: function () {
  341. return this._scroll.isScrolling;
  342. },
  343. enumerable: true,
  344. configurable: true
  345. });
  346. Object.defineProperty(Content.prototype, "directionY", {
  347. /**
  348. * The current, or last known, vertical scroll direction. Possible
  349. * string values include `down` and `up`.
  350. *
  351. * @return {string}
  352. */
  353. get: function () {
  354. return this._scroll.ev.directionY;
  355. },
  356. enumerable: true,
  357. configurable: true
  358. });
  359. Object.defineProperty(Content.prototype, "directionX", {
  360. /**
  361. * The current, or last known, horizontal scroll direction. Possible
  362. * string values include `right` and `left`.
  363. *
  364. * @return {string}
  365. */
  366. get: function () {
  367. return this._scroll.ev.directionX;
  368. },
  369. enumerable: true,
  370. configurable: true
  371. });
  372. /**
  373. * @hidden
  374. */
  375. Content.prototype.ngAfterViewInit = function () {
  376. var _this = this;
  377. (void 0) /* assert */;
  378. (void 0) /* assert */;
  379. var scroll = this._scroll;
  380. scroll.ev.fixedElement = this.getFixedElement();
  381. scroll.ev.scrollElement = this.getScrollElement();
  382. // subscribe to the scroll start
  383. scroll.onScrollStart = function (ev) {
  384. _this.ionScrollStart.emit(ev);
  385. };
  386. // subscribe to every scroll move
  387. scroll.onScroll = function (ev) {
  388. // emit to all of our other friends things be scrolling
  389. _this.ionScroll.emit(ev);
  390. _this.imgsUpdate();
  391. };
  392. // subscribe to the scroll end
  393. scroll.onScrollEnd = function (ev) {
  394. _this.ionScrollEnd.emit(ev);
  395. _this.imgsUpdate();
  396. };
  397. };
  398. /**
  399. * @hidden
  400. */
  401. Content.prototype.enableJsScroll = function () {
  402. this._scroll.enableJsScroll(this._cTop, this._cBottom);
  403. };
  404. /**
  405. * @hidden
  406. */
  407. Content.prototype.ngOnDestroy = function () {
  408. this._scLsn && this._scLsn();
  409. this._viewCtrlReadSub && this._viewCtrlReadSub.unsubscribe();
  410. this._viewCtrlWriteSub && this._viewCtrlWriteSub.unsubscribe();
  411. this._viewCtrlReadSub = this._viewCtrlWriteSub = null;
  412. this._scroll && this._scroll.destroy();
  413. this._footerEle = this._scLsn = this._scroll = null;
  414. };
  415. /**
  416. * @hidden
  417. */
  418. Content.prototype.getScrollElement = function () {
  419. return this._scrollContent.nativeElement;
  420. };
  421. /**
  422. * @private
  423. */
  424. Content.prototype.getFixedElement = function () {
  425. return this._fixedContent.nativeElement;
  426. };
  427. /**
  428. * @hidden
  429. */
  430. Content.prototype.onScrollElementTransitionEnd = function (callback) {
  431. this._plt.transitionEnd(this.getScrollElement(), callback);
  432. };
  433. /**
  434. * Scroll to the specified position.
  435. *
  436. * @param {number} x The x-value to scroll to.
  437. * @param {number} y The y-value to scroll to.
  438. * @param {number} [duration] Duration of the scroll animation in milliseconds. Defaults to `300`.
  439. * @returns {Promise} Returns a promise which is resolved when the scroll has completed.
  440. */
  441. Content.prototype.scrollTo = function (x, y, duration, done) {
  442. if (duration === void 0) { duration = 300; }
  443. (void 0) /* console.debug */;
  444. return this._scroll.scrollTo(x, y, duration, done);
  445. };
  446. /**
  447. * Scroll to the top of the content component.
  448. *
  449. * @param {number} [duration] Duration of the scroll animation in milliseconds. Defaults to `300`.
  450. * @returns {Promise} Returns a promise which is resolved when the scroll has completed.
  451. */
  452. Content.prototype.scrollToTop = function (duration) {
  453. if (duration === void 0) { duration = 300; }
  454. (void 0) /* console.debug */;
  455. return this._scroll.scrollToTop(duration);
  456. };
  457. /**
  458. * Scroll to the bottom of the content component.
  459. *
  460. * @param {number} [duration] Duration of the scroll animation in milliseconds. Defaults to `300`.
  461. * @returns {Promise} Returns a promise which is resolved when the scroll has completed.
  462. */
  463. Content.prototype.scrollToBottom = function (duration) {
  464. if (duration === void 0) { duration = 300; }
  465. (void 0) /* console.debug */;
  466. return this._scroll.scrollToBottom(duration);
  467. };
  468. Object.defineProperty(Content.prototype, "fullscreen", {
  469. /**
  470. * @input {boolean} If true, the content will scroll behind the headers
  471. * and footers. This effect can easily be seen by setting the toolbar
  472. * to transparent.
  473. */
  474. get: function () {
  475. return this._fullscreen;
  476. },
  477. set: function (val) {
  478. this._fullscreen = util_1.isTrueProperty(val);
  479. },
  480. enumerable: true,
  481. configurable: true
  482. });
  483. Object.defineProperty(Content.prototype, "scrollDownOnLoad", {
  484. /**
  485. * @input {boolean} If true, the content will scroll down on load.
  486. */
  487. get: function () {
  488. return this._scrollDownOnLoad;
  489. },
  490. set: function (val) {
  491. this._scrollDownOnLoad = util_1.isTrueProperty(val);
  492. },
  493. enumerable: true,
  494. configurable: true
  495. });
  496. /**
  497. * @private
  498. */
  499. Content.prototype.addImg = function (img) {
  500. this._imgs.push(img);
  501. };
  502. /**
  503. * @hidden
  504. */
  505. Content.prototype.removeImg = function (img) {
  506. util_1.removeArrayItem(this._imgs, img);
  507. };
  508. /**
  509. * @hidden
  510. * DOM WRITE
  511. */
  512. Content.prototype.setScrollElementStyle = function (prop, val) {
  513. var scrollEle = this.getScrollElement();
  514. if (scrollEle) {
  515. this._dom.write(function () {
  516. scrollEle.style[prop] = val;
  517. });
  518. }
  519. };
  520. /**
  521. * Returns the content and scroll elements' dimensions.
  522. * @returns {object} dimensions The content and scroll elements' dimensions
  523. * {number} dimensions.contentHeight content offsetHeight
  524. * {number} dimensions.contentTop content offsetTop
  525. * {number} dimensions.contentBottom content offsetTop+offsetHeight
  526. * {number} dimensions.contentWidth content offsetWidth
  527. * {number} dimensions.contentLeft content offsetLeft
  528. * {number} dimensions.contentRight content offsetLeft + offsetWidth
  529. * {number} dimensions.scrollHeight scroll scrollHeight
  530. * {number} dimensions.scrollTop scroll scrollTop
  531. * {number} dimensions.scrollBottom scroll scrollTop + scrollHeight
  532. * {number} dimensions.scrollWidth scroll scrollWidth
  533. * {number} dimensions.scrollLeft scroll scrollLeft
  534. * {number} dimensions.scrollRight scroll scrollLeft + scrollWidth
  535. */
  536. Content.prototype.getContentDimensions = function () {
  537. var scrollEle = this.getScrollElement();
  538. var parentElement = scrollEle.parentElement;
  539. return {
  540. contentHeight: parentElement.offsetHeight - this._cTop - this._cBottom,
  541. contentTop: this._cTop,
  542. contentBottom: this._cBottom,
  543. contentWidth: parentElement.offsetWidth,
  544. contentLeft: parentElement.offsetLeft,
  545. scrollHeight: scrollEle.scrollHeight,
  546. scrollTop: scrollEle.scrollTop,
  547. scrollWidth: scrollEle.scrollWidth,
  548. scrollLeft: scrollEle.scrollLeft,
  549. };
  550. };
  551. /**
  552. * @hidden
  553. * DOM WRITE
  554. * Adds padding to the bottom of the scroll element when the keyboard is open
  555. * so content below the keyboard can be scrolled into view.
  556. */
  557. Content.prototype.addScrollPadding = function (newPadding) {
  558. (void 0) /* assert */;
  559. if (newPadding === 0) {
  560. this._inputPolling = false;
  561. this._scrollPadding = -1;
  562. }
  563. if (newPadding > this._scrollPadding) {
  564. (void 0) /* console.debug */;
  565. this._scrollPadding = newPadding;
  566. var scrollEle = this.getScrollElement();
  567. if (scrollEle) {
  568. this._dom.write(function () {
  569. scrollEle.style.paddingBottom = (newPadding > 0) ? newPadding + 'px' : '';
  570. });
  571. }
  572. }
  573. };
  574. /**
  575. * @hidden
  576. * DOM WRITE
  577. */
  578. Content.prototype.clearScrollPaddingFocusOut = function () {
  579. var _this = this;
  580. if (!this._inputPolling) {
  581. (void 0) /* console.debug */;
  582. this._inputPolling = true;
  583. this._keyboard.onClose(function () {
  584. (void 0) /* console.debug */;
  585. _this.addScrollPadding(0);
  586. }, 200, 3000);
  587. }
  588. };
  589. /**
  590. * Tell the content to recalculate its dimensions. This should be called
  591. * after dynamically adding/removing headers, footers, or tabs.
  592. */
  593. Content.prototype.resize = function () {
  594. this._dom.read(this._readDimensions.bind(this));
  595. this._dom.write(this._writeDimensions.bind(this));
  596. };
  597. /**
  598. * @hidden
  599. * DOM READ
  600. */
  601. Content.prototype._readDimensions = function () {
  602. var cachePaddingTop = this._pTop;
  603. var cachePaddingRight = this._pRight;
  604. var cachePaddingBottom = this._pBottom;
  605. var cachePaddingLeft = this._pLeft;
  606. var cacheHeaderHeight = this._hdrHeight;
  607. var cacheFooterHeight = this._ftrHeight;
  608. var cacheTabsPlacement = this._tabsPlacement;
  609. var tabsTop = 0;
  610. var scrollEvent;
  611. this._pTop = 0;
  612. this._pRight = 0;
  613. this._pBottom = 0;
  614. this._pLeft = 0;
  615. this._hdrHeight = 0;
  616. this._ftrHeight = 0;
  617. this._tabsPlacement = null;
  618. this._tTop = 0;
  619. this._fTop = 0;
  620. this._fBottom = 0;
  621. // In certain cases this._scroll is undefined
  622. // if that is the case then we should just return
  623. if (!this._scroll) {
  624. return;
  625. }
  626. scrollEvent = this._scroll.ev;
  627. var ele = this.getNativeElement();
  628. if (!ele) {
  629. (void 0) /* assert */;
  630. return;
  631. }
  632. var computedStyle;
  633. var tagName;
  634. var parentEle = ele.parentElement;
  635. var children = parentEle.children;
  636. for (var i = children.length - 1; i >= 0; i--) {
  637. ele = children[i];
  638. tagName = ele.tagName;
  639. if (tagName === 'ION-CONTENT') {
  640. scrollEvent.contentElement = ele;
  641. if (this._fullscreen) {
  642. // ******** DOM READ ****************
  643. computedStyle = getComputedStyle(ele);
  644. this._pTop = parsePxUnit(computedStyle.paddingTop);
  645. this._pBottom = parsePxUnit(computedStyle.paddingBottom);
  646. this._pRight = parsePxUnit(computedStyle.paddingRight);
  647. this._pLeft = parsePxUnit(computedStyle.paddingLeft);
  648. }
  649. }
  650. else if (tagName === 'ION-HEADER') {
  651. scrollEvent.headerElement = ele;
  652. // ******** DOM READ ****************
  653. this._hdrHeight = ele.clientHeight;
  654. }
  655. else if (tagName === 'ION-FOOTER') {
  656. scrollEvent.footerElement = ele;
  657. // ******** DOM READ ****************
  658. this._ftrHeight = ele.clientHeight;
  659. this._footerEle = ele;
  660. }
  661. }
  662. ele = parentEle;
  663. var tabbarEle;
  664. while (ele && ele.tagName !== 'ION-MODAL' && !ele.classList.contains('tab-subpage')) {
  665. if (ele.tagName === 'ION-TABS') {
  666. tabbarEle = ele.firstElementChild;
  667. // ******** DOM READ ****************
  668. this._tabbarHeight = tabbarEle.clientHeight;
  669. if (this._tabsPlacement === null) {
  670. // this is the first tabbar found, remember it's position
  671. this._tabsPlacement = ele.getAttribute('tabsplacement');
  672. }
  673. }
  674. ele = ele.parentElement;
  675. }
  676. // Tabs top
  677. if (this._tabs && this._tabsPlacement === 'top') {
  678. this._tTop = this._hdrHeight;
  679. tabsTop = this._tabs._top;
  680. }
  681. // Toolbar height
  682. this._cTop = this._hdrHeight;
  683. this._cBottom = this._ftrHeight;
  684. // Tabs height
  685. if (this._tabsPlacement === 'top') {
  686. this._cTop += this._tabbarHeight;
  687. }
  688. else if (this._tabsPlacement === 'bottom') {
  689. this._cBottom += this._tabbarHeight;
  690. }
  691. // Refresher uses a border which should be hidden unless pulled
  692. if (this._hasRefresher) {
  693. this._cTop -= 1;
  694. }
  695. // Fixed content shouldn't include content padding
  696. this._fTop = this._cTop;
  697. this._fBottom = this._cBottom;
  698. // Handle fullscreen viewport (padding vs margin)
  699. if (this._fullscreen) {
  700. this._cTop += this._pTop;
  701. this._cBottom += this._pBottom;
  702. }
  703. // ******** DOM READ ****************
  704. var contentDimensions = this.getContentDimensions();
  705. scrollEvent.scrollHeight = contentDimensions.scrollHeight;
  706. scrollEvent.scrollWidth = contentDimensions.scrollWidth;
  707. scrollEvent.contentHeight = contentDimensions.contentHeight;
  708. scrollEvent.contentWidth = contentDimensions.contentWidth;
  709. scrollEvent.contentTop = contentDimensions.contentTop;
  710. scrollEvent.contentBottom = contentDimensions.contentBottom;
  711. this._dirty = (cachePaddingTop !== this._pTop ||
  712. cachePaddingBottom !== this._pBottom ||
  713. cachePaddingLeft !== this._pLeft ||
  714. cachePaddingRight !== this._pRight ||
  715. cacheHeaderHeight !== this._hdrHeight ||
  716. cacheFooterHeight !== this._ftrHeight ||
  717. cacheTabsPlacement !== this._tabsPlacement ||
  718. tabsTop !== this._tTop ||
  719. this._cTop !== this.contentTop ||
  720. this._cBottom !== this.contentBottom);
  721. this._scroll.init(this.getScrollElement(), this._cTop, this._cBottom);
  722. // initial imgs refresh
  723. this.imgsUpdate();
  724. };
  725. /**
  726. * @hidden
  727. * DOM WRITE
  728. */
  729. Content.prototype._writeDimensions = function () {
  730. if (!this._dirty) {
  731. (void 0) /* console.debug */;
  732. return;
  733. }
  734. var scrollEle = this.getScrollElement();
  735. if (!scrollEle) {
  736. (void 0) /* assert */;
  737. return;
  738. }
  739. var fixedEle = this.getFixedElement();
  740. if (!fixedEle) {
  741. (void 0) /* assert */;
  742. return;
  743. }
  744. // Tabs height
  745. if (this._tabsPlacement === 'bottom' && this._cBottom > 0 && this._footerEle) {
  746. var footerPos = this._cBottom - this._ftrHeight;
  747. (void 0) /* assert */;
  748. // ******** DOM WRITE ****************
  749. this._footerEle.style.bottom = cssFormat(footerPos);
  750. }
  751. // Handle fullscreen viewport (padding vs margin)
  752. var topProperty = 'marginTop';
  753. var bottomProperty = 'marginBottom';
  754. var fixedTop = this._fTop;
  755. var fixedBottom = this._fBottom;
  756. if (this._fullscreen) {
  757. (void 0) /* assert */;
  758. (void 0) /* assert */;
  759. // adjust the content with padding, allowing content to scroll under headers/footers
  760. // however, on iOS you cannot control the margins of the scrollbar (last tested iOS9.2)
  761. // only add inline padding styles if the computed padding value, which would
  762. // have come from the app's css, is different than the new padding value
  763. topProperty = 'paddingTop';
  764. bottomProperty = 'paddingBottom';
  765. }
  766. // Only update top margin if value changed
  767. if (this._cTop !== this.contentTop) {
  768. (void 0) /* assert */;
  769. (void 0) /* assert */;
  770. // ******** DOM WRITE ****************
  771. scrollEle.style[topProperty] = cssFormat(this._cTop);
  772. // ******** DOM WRITE ****************
  773. fixedEle.style.marginTop = cssFormat(fixedTop);
  774. this.contentTop = this._cTop;
  775. }
  776. // Only update bottom margin if value changed
  777. if (this._cBottom !== this.contentBottom) {
  778. (void 0) /* assert */;
  779. (void 0) /* assert */;
  780. // ******** DOM WRITE ****************
  781. scrollEle.style[bottomProperty] = cssFormat(this._cBottom);
  782. // ******** DOM WRITE ****************
  783. fixedEle.style.marginBottom = cssFormat(fixedBottom);
  784. this.contentBottom = this._cBottom;
  785. }
  786. if (this._tabsPlacement !== null && this._tabs) {
  787. // set the position of the tabbar
  788. if (this._tabsPlacement === 'top') {
  789. // ******** DOM WRITE ****************
  790. this._tabs.setTabbarPosition(this._tTop, -1);
  791. }
  792. else {
  793. (void 0) /* assert */;
  794. // ******** DOM WRITE ****************
  795. this._tabs.setTabbarPosition(-1, 0);
  796. }
  797. }
  798. // Scroll the page all the way down after setting dimensions
  799. if (this._scrollDownOnLoad) {
  800. this.scrollToBottom(0);
  801. this._scrollDownOnLoad = false;
  802. }
  803. };
  804. /**
  805. * @hidden
  806. */
  807. Content.prototype.imgsUpdate = function () {
  808. if (this._scroll.initialized && this._imgs.length && this.isImgsUpdatable()) {
  809. updateImgs(this._imgs, this.scrollTop, this.contentHeight, this.directionY, this._imgReqBfr, this._imgRndBfr);
  810. }
  811. };
  812. /**
  813. * @hidden
  814. */
  815. Content.prototype.isImgsUpdatable = function () {
  816. // an image is only "updatable" if the content isn't scrolling too fast
  817. // if scroll speed is above the maximum velocity, then let current
  818. // requests finish, but do not start new requets or render anything
  819. // if scroll speed is below the maximum velocity, then it's ok
  820. // to start new requests and render images
  821. return Math.abs(this._scroll.ev.velocityY) < this._imgVelMax;
  822. };
  823. Content.decorators = [
  824. { type: core_1.Component, args: [{
  825. selector: 'ion-content',
  826. template: '<div class="fixed-content" #fixedContent>' +
  827. '<ng-content select="[ion-fixed],ion-fab"></ng-content>' +
  828. '</div>' +
  829. '<div class="scroll-content" #scrollContent>' +
  830. '<ng-content></ng-content>' +
  831. '</div>' +
  832. '<ng-content select="ion-refresher"></ng-content>',
  833. host: {
  834. '[class.statusbar-padding]': 'statusbarPadding',
  835. '[class.has-refresher]': '_hasRefresher'
  836. },
  837. changeDetection: core_1.ChangeDetectionStrategy.OnPush,
  838. encapsulation: core_1.ViewEncapsulation.None
  839. },] },
  840. ];
  841. /** @nocollapse */
  842. Content.ctorParameters = function () { return [
  843. { type: config_1.Config, },
  844. { type: platform_1.Platform, },
  845. { type: dom_controller_1.DomController, },
  846. { type: core_1.ElementRef, },
  847. { type: core_1.Renderer, },
  848. { type: app_1.App, },
  849. { type: keyboard_1.Keyboard, },
  850. { type: core_1.NgZone, },
  851. { type: view_controller_1.ViewController, decorators: [{ type: core_1.Optional },] },
  852. { type: nav_controller_1.NavController, decorators: [{ type: core_1.Optional },] },
  853. ]; };
  854. Content.propDecorators = {
  855. '_fixedContent': [{ type: core_1.ViewChild, args: ['fixedContent', { read: core_1.ElementRef },] },],
  856. '_scrollContent': [{ type: core_1.ViewChild, args: ['scrollContent', { read: core_1.ElementRef },] },],
  857. 'ionScrollStart': [{ type: core_1.Output },],
  858. 'ionScroll': [{ type: core_1.Output },],
  859. 'ionScrollEnd': [{ type: core_1.Output },],
  860. 'fullscreen': [{ type: core_1.Input },],
  861. 'scrollDownOnLoad': [{ type: core_1.Input },],
  862. };
  863. return Content;
  864. }(ion_1.Ion));
  865. exports.Content = Content;
  866. function updateImgs(imgs, viewableTop, contentHeight, scrollDirectionY, requestableBuffer, renderableBuffer) {
  867. // ok, so it's time to see which images, if any, should be requested and rendered
  868. // ultimately, if we're scrolling fast then don't bother requesting or rendering
  869. // when scrolling is done, then it needs to do a check to see which images are
  870. // important to request and render, and which image requests should be aborted.
  871. // Additionally, images which are not near the viewable area should not be
  872. // rendered at all in order to save browser resources.
  873. var viewableBottom = (viewableTop + contentHeight);
  874. var priority1 = [];
  875. var priority2 = [];
  876. var img;
  877. // all images should be paused
  878. for (var i = 0, ilen = imgs.length; i < ilen; i++) {
  879. img = imgs[i];
  880. if (scrollDirectionY === 'up') {
  881. // scrolling up
  882. if (img.top < viewableBottom && img.bottom > viewableTop - renderableBuffer) {
  883. // scrolling up, img is within viewable area
  884. // or about to be viewable area
  885. img.canRequest = img.canRender = true;
  886. priority1.push(img);
  887. continue;
  888. }
  889. if (img.bottom <= viewableTop && img.bottom > viewableTop - requestableBuffer) {
  890. // scrolling up, img is within requestable area
  891. img.canRequest = true;
  892. img.canRender = false;
  893. priority2.push(img);
  894. continue;
  895. }
  896. if (img.top >= viewableBottom && img.top < viewableBottom + renderableBuffer) {
  897. // scrolling up, img below viewable area
  898. // but it's still within renderable area
  899. // don't allow a reset
  900. img.canRequest = img.canRender = false;
  901. continue;
  902. }
  903. }
  904. else {
  905. // scrolling down
  906. if (img.bottom > viewableTop && img.top < viewableBottom + renderableBuffer) {
  907. // scrolling down, img is within viewable area
  908. // or about to be viewable area
  909. img.canRequest = img.canRender = true;
  910. priority1.push(img);
  911. continue;
  912. }
  913. if (img.top >= viewableBottom && img.top < viewableBottom + requestableBuffer) {
  914. // scrolling down, img is within requestable area
  915. img.canRequest = true;
  916. img.canRender = false;
  917. priority2.push(img);
  918. continue;
  919. }
  920. if (img.bottom <= viewableTop && img.bottom > viewableTop - renderableBuffer) {
  921. // scrolling down, img above viewable area
  922. // but it's still within renderable area
  923. // don't allow a reset
  924. img.canRequest = img.canRender = false;
  925. continue;
  926. }
  927. }
  928. img.canRequest = img.canRender = false;
  929. img.reset();
  930. }
  931. // update all imgs which are viewable
  932. priority1.sort(sortTopToBottom).forEach(function (i) { return i.update(); });
  933. if (scrollDirectionY === 'up') {
  934. // scrolling up
  935. priority2.sort(sortTopToBottom).reverse().forEach(function (i) { return i.update(); });
  936. }
  937. else {
  938. // scrolling down
  939. priority2.sort(sortTopToBottom).forEach(function (i) { return i.update(); });
  940. }
  941. }
  942. exports.updateImgs = updateImgs;
  943. function sortTopToBottom(a, b) {
  944. if (a.top < b.top) {
  945. return -1;
  946. }
  947. if (a.top > b.top) {
  948. return 1;
  949. }
  950. return 0;
  951. }
  952. function parsePxUnit(val) {
  953. return (val.indexOf('px') > 0) ? parseInt(val, 10) : 0;
  954. }
  955. function cssFormat(val) {
  956. return (val > 0 ? val + 'px' : '');
  957. }
  958. });
  959. //# sourceMappingURL=content.js.map