Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(item-reorder): add side support #11642

Merged
merged 14 commits into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/item/item-reorder-gesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { indexForItem, findReorderItem } from './item-reorder-util';
import { Platform } from '../../platform/platform';
import { PointerCoordinates, pointerCoord } from '../../util/dom';
import { UIEventManager } from '../../gestures/ui-event-manager';
import { isRightSide, Side } from '../../util/util';


/**
Expand Down Expand Up @@ -134,7 +135,7 @@ export class ItemReorderGesture {
}

private itemForCoord(coord: PointerCoordinates): HTMLElement {
const sideOffset = this.plt.isRTL ? 100 : -100;
const sideOffset = isRightSide(this.reorderList.side, this.plt.isRTL) ? -100 : 100;
const x = this.offset.x + sideOffset;
const y = coord.y;
const element = this.plt.getElementFromPoint(x, y);
Expand Down Expand Up @@ -167,6 +168,7 @@ const SCROLL_JUMP = 10;
const ITEM_REORDER_ACTIVE = 'reorder-active';

export interface ItemReorderGestureDelegate {
side: Side;
getNativeElement: () => any;
_reorderPrepare: () => void;
_scrollContent: (scrollPosition: number) => number;
Expand Down
7 changes: 6 additions & 1 deletion src/components/item/item-reorder.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ ion-reorder {
font-size: 1.7em;
opacity: .25;


transition: transform 140ms ease-in;

pointer-events: all;
touch-action: manipulation;
}

.reorder-side-start ion-reorder {
@include transform(translate3d(-160%, 0, 0));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in other to prevent DRY, could we use a scss variable like $reorder-initial-transform ?


order: -1;
}

ion-reorder ion-icon {
pointer-events: none;
}
Expand Down
6 changes: 6 additions & 0 deletions src/components/item/item-reorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export class ReorderIndexes {
host: {
'[class.reorder-enabled]': '_enableReorder',
'[class.reorder-visible]': '_visibleReorder',
'[class.reorder-side-start]': 'side === "start"'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change string comparison to boolean

}
})
export class ItemReorder implements ItemReorderGestureDelegate {
Expand All @@ -158,6 +159,11 @@ export class ItemReorder implements ItemReorderGestureDelegate {
*/
@Output() ionItemReorder: EventEmitter<ReorderIndexes> = new EventEmitter<ReorderIndexes>();

/**
* @input {string} Which side of the view the ion-reorder should be placed. Default `"end"`.
*/
@Input() side: 'start' | 'end' = 'end';

constructor(
private _plt: Platform,
private _dom: DomController,
Expand Down
32 changes: 18 additions & 14 deletions src/components/item/test/reorder/pages/root-page/root-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,28 @@

<ion-list [reorder]="isReordering" (ionItemReorder)="reorder($event)">
<button ion-item *ngFor="let item of items" (click)="clickedButton(item)"
[style.background]="'rgb('+(255-item*4)+','+(255-item*4)+','+(255-item*4)+')'"
[style.min-height]="item*2+35+'px'">
[style.background]="'rgb('+(255-item*4)+','+(255-item*4)+','+(255-item*4)+')'"
[style.min-height]="item*2+35+'px'">
{{item}}
</button>
</ion-list>

<ion-list [reorder]="isReordering" (ionItemReorder)="$event.applyTo(items)">
<ion-item-sliding *ngFor="let item of items">
<button ion-item (click)="clickedButton(item)">
<h2>Sliding item {{item}}</h2>
</button>
<ion-item-options side="right" icon-start>
<button ion-button color='danger'>
<ion-icon name="trash"></ion-icon>
Remove
<div *ngFor="let side of ['start', 'end']">
<ion-list [reorder]="isReordering" (ionItemReorder)="$event.applyTo(items)" [side]="side">
<ion-list-header>{{side}}</ion-list-header>
<ion-item-sliding *ngFor="let item of items">
<button ion-item (click)="clickedButton(item)">
<h2>Sliding item {{item}}</h2>
<div item-right>right</div>
</button>
</ion-item-options>
</ion-item-sliding>
</ion-list>
<ion-item-options side="right" icon-left>
<button ion-button color='danger'>
<ion-icon name="trash"></ion-icon>
Remove
</button>
</ion-item-options>
</ion-item-sliding>
</ion-list>
</div>

</ion-content>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class RootPage {
isReordering: boolean = false;

constructor() {
let nu = 9;
let nu = 5;
for (let i = 0; i < nu; i++) {
this.items.push(i);
}
Expand Down