SortableJS / ngx-sortablejs

Angular 2+ binding to SortableJS. Previously known as angular-sortablejs
https://sortablejs.github.io/ngx-sortablejs/
MIT License
466 stars 160 forks source link

Custom delete button not working in mobile devices. #213

Open xtreemMobile opened 3 years ago

xtreemMobile commented 3 years ago

Hello,

Greetings!!

I'm using the ngx-sortablejs for change the position of the elements. I have added the custom delete button for remove the particular element.

I'm using the following code:

<ul id="image-list" [sortablejs]="place_images"> <li *ngFor="let place_image of place_images; let i = index">

images Modify
order
</li>

removeImage(i, id) { // delete element code goes here }

The above code is working fine in the Desktop and some mobile devices. But in the another mobile device's, it's not working. On the click on item, the drag feature enabled instead of delete function.

Could you please help me out for solve the problem?

Thanks In Advance

RemcovandenBerg commented 2 years ago

Try excluding your delete button by using the filter:

  private filterSortable(event: PointerEvent): boolean {
    // using closest to find if there is a parent with class, target often is svg-element
    const isRemoveIcon = (event.target as HTMLElement).closest('.remove-icon-box');
    return !this.editModeActive || !!isRemoveIcon;
  }
abcdleandro commented 1 year ago

I had the same problem, I just disabled drag action in element, check the doc.

filter: ".ignore-elements", // Selectors that do not lead to dragging (String or Function)

Work for me!