【问题标题】:Drag and Drop in Aurelia not workingAurelia中的拖放不起作用
【发布时间】:2015-04-06 02:36:51
【问题描述】:

我正在尝试为 Aurelia 创建一个拖放控件。最初,它工作得很好。

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

但是,当我将侦听器委托给 dragstart 事件时,拖动不再起作用。

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

我可以触发 dragstart 事件,并且该事件有 defaultPrevented: true,这会阻止默认的拖动事件启动。如何在 Aurelia 的特定事件委托人上禁用 preventDefault

【问题讨论】:

标签: drag-and-drop ecmascript-6 aurelia


【解决方案1】:

此增强功能为added。要禁用 defaultPrevented,请从事件处理程序返回 true:

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

在这种特殊情况下,您需要返回 true 以启用默认拖动行为。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-10
    • 1970-01-01
    • 2016-07-10
    • 2015-08-10
    • 2018-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多