UI for Zipcoin Blue

item-reorder.d.ts 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. import { ElementRef, EventEmitter, NgZone, Renderer } from '@angular/core';
  2. import { Content } from '../content/content';
  3. import { DomController } from '../../platform/dom-controller';
  4. import { ItemReorderGesture, ItemReorderGestureDelegate } from './item-reorder-gesture';
  5. import { Platform } from '../../platform/platform';
  6. export declare class ReorderIndexes {
  7. from: number;
  8. to: number;
  9. constructor(from: number, to: number);
  10. applyTo(array: any): void;
  11. }
  12. /**
  13. * @name ItemReorder
  14. * @description
  15. * Item reorder adds the ability to change an item's order in a group.
  16. * It can be used within an `ion-list` or `ion-item-group` to provide a
  17. * visual drag and drop interface.
  18. *
  19. * ## Grouping Items
  20. *
  21. * All reorderable items must be grouped in the same element. If an item
  22. * should not be reordered, it shouldn't be included in this group. For
  23. * example, the following code works because the items are grouped in the
  24. * `<ion-list>`:
  25. *
  26. * ```html
  27. * <ion-list reorder="true">
  28. * <ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %}</ion-item>
  29. * </ion-list>
  30. * ```
  31. *
  32. * However, the below list includes a header that shouldn't be reordered:
  33. *
  34. * ```html
  35. * <ion-list reorder="true">
  36. * <ion-list-header>Header</ion-list-header>
  37. * <ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %}</ion-item>
  38. * </ion-list>
  39. * ```
  40. *
  41. * In order to mix different sets of items, `ion-item-group` should be used to
  42. * group the reorderable items:
  43. *
  44. * ```html
  45. * <ion-list>
  46. * <ion-list-header>Header</ion-list-header>
  47. * <ion-item-group reorder="true">
  48. * <ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %}</ion-item>
  49. * </ion-item-group>
  50. * </ion-list>
  51. * ```
  52. *
  53. * It's important to note that in this example, the `[reorder]` directive is applied to
  54. * the `<ion-item-group>` instead of the `<ion-list>`. This way makes it possible to
  55. * mix items that should and shouldn't be reordered.
  56. *
  57. *
  58. * ## Implementing the Reorder Function
  59. *
  60. * When the item is dragged and dropped into the new position, the `(ionItemReorder)` event is
  61. * emitted. This event provides the initial index (from) and the new index (to) of the reordered
  62. * item. For example, if the first item is dragged to the fifth position, the event will emit
  63. * `{from: 0, to: 4}`. Note that the index starts at zero.
  64. *
  65. * A function should be called when the event is emitted that handles the reordering of the items.
  66. * See [usage](#usage) below for some examples.
  67. *
  68. *
  69. * @usage
  70. *
  71. * ```html
  72. * <ion-list>
  73. * <ion-list-header>Header</ion-list-header>
  74. * <ion-item-group reorder="true" (ionItemReorder)="reorderItems($event)">
  75. * <ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %}</ion-item>
  76. * </ion-item-group>
  77. * </ion-list>
  78. * ```
  79. *
  80. * ```ts
  81. * class MyComponent {
  82. * items = [];
  83. *
  84. * constructor() {
  85. * for (let x = 0; x < 5; x++) {
  86. * this.items.push(x);
  87. * }
  88. * }
  89. *
  90. * reorderItems(indexes) {
  91. * let element = this.items[indexes.from];
  92. * this.items.splice(indexes.from, 1);
  93. * this.items.splice(indexes.to, 0, element);
  94. * }
  95. * }
  96. * ```
  97. *
  98. * Ionic also provides a helper function called `reorderArray` to
  99. * reorder the array of items. This can be used instead:
  100. *
  101. * ```ts
  102. * import { reorderArray } from 'ionic-angular';
  103. *
  104. * class MyComponent {
  105. * items = [];
  106. *
  107. * constructor() {
  108. * for (let x = 0; x < 5; x++) {
  109. * this.items.push(x);
  110. * }
  111. * }
  112. *
  113. * reorderItems(indexes) {
  114. * this.items = reorderArray(this.items, indexes);
  115. * }
  116. * }
  117. * ```
  118. * Alternatevely you can execute helper function inside template:
  119. *
  120. * ```html
  121. * <ion-list>
  122. * <ion-list-header>Header</ion-list-header>
  123. * <ion-item-group reorder="true" (ionItemReorder)="$event.applyTo(items)">
  124. * <ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %}</ion-item>
  125. * </ion-item-group>
  126. * </ion-list>
  127. * ```
  128. *
  129. * @demo /docs/demos/src/item-reorder/
  130. * @see {@link /docs/components#lists List Component Docs}
  131. * @see {@link ../../list/List List API Docs}
  132. * @see {@link ../Item Item API Docs}
  133. */
  134. export declare class ItemReorder implements ItemReorderGestureDelegate {
  135. private _plt;
  136. private _dom;
  137. private _rendered;
  138. private _zone;
  139. private _content;
  140. _enableReorder: boolean;
  141. _visibleReorder: boolean;
  142. _isStart: boolean;
  143. _reorderGesture: ItemReorderGesture;
  144. _lastToIndex: number;
  145. _element: HTMLElement;
  146. /**
  147. * @output {object} Emitted when the item is reordered. Emits an object
  148. * with `from` and `to` properties.
  149. */
  150. ionItemReorder: EventEmitter<ReorderIndexes>;
  151. /**
  152. * @input {string} Which side of the view the ion-reorder should be placed. Default `"end"`.
  153. */
  154. side: 'start' | 'end';
  155. constructor(_plt: Platform, _dom: DomController, elementRef: ElementRef, _rendered: Renderer, _zone: NgZone, _content: Content);
  156. /**
  157. * @hidden
  158. */
  159. ngOnDestroy(): void;
  160. /**
  161. * @hidden
  162. */
  163. reorder: boolean;
  164. _reorderPrepare(): void;
  165. _reorderStart(): void;
  166. _reorderEmit(fromIndex: number, toIndex: number): void;
  167. _scrollContent(scroll: number): number;
  168. _reorderReset(): void;
  169. _reorderMove(fromIndex: number, toIndex: number, itemHeight: number): void;
  170. /**
  171. * @hidden
  172. */
  173. setElementClass(classname: string, add: boolean): void;
  174. /**
  175. * @hidden
  176. */
  177. getNativeElement(): HTMLElement;
  178. }