Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drag and Drop in Aurelia not working

I am trying to create a drag and drop control for Aurelia. Initially, it works just fine.

<div class="card" draggable="true" repeat.for="card of player2.hand">

However, when I delegate a listener to the dragstart event, the drag no longer works.

<div class="card" draggable="true" dragstart.delegate="$parent.dragstart()" repeat.for="card of player2.hand">

I can get the dragstart event to fire and the event has defaultPrevented: true, which keeps the default drag event from starting. How can I disable preventDefault on a particular event delegator in Aurelia?

like image 274
Matthew James Davis Avatar asked Feb 06 '15 02:02

Matthew James Davis


1 Answers

This enhancement has been added. To disable defaultPrevented, return true from your event handler:

function dragStart() {
    // do stuff
    return true;
}

In this particular case, you need to return true to enable the default drag behavior.

like image 110
Matthew James Davis Avatar answered Oct 01 '22 20:10

Matthew James Davis