简体   繁体   English

如何在拖动时使项目恢复到原始位置?

[英]How to make an item revert back to its original position on drag?

So far I've got this: 到目前为止,我已经知道了:

$(function() {
    $("#draggable").draggable({
        drag: function(event, ui) {
            $(this)
                .addClass("choppedonion")
                .find("section")
                .html("");
        }
    });
});

But I would also like it to revert back to its original position when dragged. 但是,我也希望它在拖动时恢复到其原始位置。

The jQueryUI sites give you an example of that: http://jqueryui.com/draggable/#revert jQueryUI网站为您提供了一个示例: http : //jqueryui.com/draggable/#revert

Just set the revert option to true: 只需将revert选项设置为true即可:

$('#draggable').draggable({
    revert: true,
    drag: function() {},
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单击任何其他项目时如何将(最后单击的列表项目)恢复为原始颜色 - React hooks - how to revert (last clicked list item) back to its original color when any other item is clicked - react hooks 如果无法通过验证,是否有办法将Jquery拖放的可拖动对象恢复为其原始位置? - Is there a way to revert the Jquery drag-drop draggable to its original position if it fails validation? 点击事件 - 如何让点击事件逐渐恢复到原来的状态 - click event - how to make click event revert back to original gradually 在动画制作后,如何让div跳回到原来的位置? - How do I make a div jump back to its original position after it animates? 如何让一个元素在滚动事件中改变它的颜色然后恢复到原来的颜色? - How to have an element change its color during a scroll event and then revert back to its original color? jQuery拖放拖放到原始位置并双击div - Jquery drag drop revert to original position and div on double click 如何将javascript恢复为原始状态 - How to revert javascript back to original status 如何退货 <Rect/> 在React + Konva中拖动后,元素返回到原始位置 - How to return <Rect/> element back to original position after drag in React + Konva 我可以使用jQuery为我下拉菜单。 如何使用jQuery将其恢复到原始位置? - I am able to make a menu drop down for me using jQuery. How can I make it go back to its original position using jQuery? 如何在 React (useState) 中制作相同的按钮以增加计数并恢复到以前的状态? - How to make same button to increase count and revert back to its previous state in React (useState)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM