![](/img/trans.png)
[英]How do you do something when the escape key is pressed on an input field, but not on blur events for that input field?
[英]How do you cancel drag with Escape key
拜托,您是否有任何想法如何使用“退出”按鈕取消拖放並將拖動的項目返回到其原始位置?
我正在使用https://github.com/RubaXa/Sortable ,代碼是:
Sortable.create(shelf2, {
animation: 200,
group: {
name: "shared",
revertClone: true
},
sort: true,
// Set the delay for the Drag&Drop effect
delay: 1000,
ghostClass: "sortable-ghost",
chosenClass: "sortable-chosen"
});
這是Codepen上的完整示例: https ://codepen.io/vlastapolach/pen/xreXpv
有什么想法嗎?
通過切換到其他庫jQueryUI並調用其本機的Cancel方法解決了問題:
$(document).keyup(function(e) {
if (e.which === 27 || e.keyCode === 27) {
$("#shelf1, #shelf2").sortable("cancel");
}
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.