javascript - Does Dragula accepts buffer the answer?
问题描述
I'm using dragula and wanted to have a heading within each container. I've managed to make the heading non-draggable via the moves
attribute, but, then I also wanted to prohibit that elements can be dropped above the heading so I added:
accepts: function (el, target) {
var itemPos = Array.from(el.parentNode.children).indexOf(el);
var acceptDrop = itemPos > 0;
console.log("Accept Drop = " + acceptDrop);
return acceptDrop;
},
In the console log, I can see that the acceptDrop
is false
when I move an element to the first position but the drop is possible anyway! But then I can't move it from that position. I.e. If the accepts returns false
when the drag is initiated I can't drop the item anywhere, but if it starts with true
I can drop it everywhere. Am I missing something or how can I make this dynamic and prevent drops at position zero?
(I know that I can put the heading outside the container with draggable items but that needs extra HTML nesting that shouldn't be needed)
解决方案
推荐阅读
- android - 为什么 GMSGroundOverlay 图标没有在 GoogleMaps 中填充其边界?
- clojurescript - 在 cljs 中导入时 ajax.edn 不可用
- mysql - MYSQL将UNC时间插入列中,但出现错误
- java - 使用 getter 方法时出现错误(HttpMessageNotWritableException:无法写入 JSON:bean 类的无效属性“”)
- git - Unity 和 Github 场景合并
- azure-cognitive-search - 索引合并后自动更新的字段
- javascript - 为什么 new Uint8ClampedArray 的 new ImageData 会创建黑白图像
- python - Write PIL image to EXR using OpenEXR in Python
- scrapy - 有没有办法在 scrapy 中的 reactor.run() 之后运行代码?
- algorithm - 一组替代算法中的最大非重叠间隔数?