I’m playing with ionic v4
and trying to combine reorder
with item-sliding
to delete a row. It sort of works, but once I reorder a row, the rows which were moved no longer slide. any suggestions? This is what I have against the blank
template
file home.page.html
<ion-grid fixed>
<ion-row>
<ion-col size="6">
<ion-list id="sliding-list-1">
<ion-text color="primary"><ion-reorder-group> with <ion-item-sliding></ion-text>
<ion-reorder-group disabled="false"
(ionItemReorder)="reorder($event)">
<ion-item-sliding *ngFor="let item of items"
(click)="close($event, item)">
<ion-item>
<ion-label>{{item}}</ion-label>
<ion-reorder slot="end"></ion-reorder>
</ion-item>
<ion-item-options>
<ion-item-option color="danger" slot="top" (click)="delete($event, item)">
<ion-icon name="trash" slot="top"></ion-icon>
<ion-label>Delete</ion-label>
</ion-item-option>
</ion-item-options>
</ion-item-sliding>
</ion-reorder-group>
</ion-list>
</ion-col>
</ion-row>
</ion-grid>
file home.page.ts
export class HomePage {
public items:string[] = ['dogs', 'cats', 'birds', 'fishes', 'emus'];
public remove(item:string){
console.log("reomove: ", item)
}
public reorder(ev){
const {from, to} = ev.detail;
const log = `${this.items[from]} moved to position ${to}: `;
this.items.splice(to, 0, this.items.splice(from, 1)[0]);
console.log( log, this.items )
}
public delete(o, item) {
this.close(o, item)
this.items = this.items.filter( v=>v!=item)
this.remove(item)
}
public close(o, item){
const el = o.currentTarget.closest('ion-item-sliding');
el.close()
console.log("Close:", item)
}
}
any ideas?