角拖放事件在移动设备中不起作用

时间:2020-02-21 08:53:01

标签: typescript drag-and-drop angular6

我一直在引用以下帖子。

Drag and Drop Javascript not working on Mobile Devices

html5 drag and drop FOR MOBILE

HTML Drag And Drop On Mobile Devices

正常角度6拖放似乎在移动设备上不起作用。我发现它不能在手机上使用。

根据此this comment,大多数移动设备不会监听绑定到DOM的拖动事件。 touchmove事件及其伴随的事件可能会起作用。

我用过

touchstart而不是dragstart

touchend而不是drop

触摸移动而不是拖动。

我将ngIf应用于移动设备和Web界面的切换。似乎没有用。 有任何改进建议或答案以应用更好的解决方案吗?

<div class="row-fluid food_item_list" *ngIf="(deviceType == deviceTypes.Web )" (drop)="drop($event, 1)" (dragover)="allowDrop($event)" [ngClass]="{'custom-border':unSelectedfoodItemsList?.length > 0}">
  <table class="table draggable-table">
    <tbody *ngIf="unSelectedfoodItemsList?.length > 0 ;else noDataTmplt1">
      <tr *ngFor="let item of unSelectedfoodItemsList" draggable="true" (dragstart)="drag($event, 1)" attr.itemId={{item.items_id}}>
        <td>{{item.name}}</td>
      </tr>
    </tbody>
  </table>
</div>

<div class="row-fluid  food_item_list" *ngIf="(deviceType == deviceTypes.Tablet || deviceType == deviceTypes.Mobile )" (touchend)="drop($event, 1)" (touchmove)="allowDrop($event)" [ngClass]="{'custom-border':unSelectedfoodItemsList?.length > 0}">
  <table class="table draggable-table">
    <tbody *ngIf="unSelectedfoodItemsList?.length > 0 ;else noDataTmplt1">
      <tr *ngFor="let item of unSelectedfoodItemsList" draggable="true" (touchstart)="drag($event, 1)" attr.itemId={{item.items_id}}>
        <td>{{item.name}}</td>
      </tr>
    </tbody>
  </table>
</div>

0 个答案:

没有答案