简体   繁体   English

来自https://github.com/RubaXa/Sortable的功能要求

[英]Function required from https://github.com/RubaXa/Sortable

I am using https://github.com/RubaXa/Sortable and i need to write an if/else function that can basically tell if you have dragged the right tile to the right target and if you haven't, bounce it back to where it came from (same order). 我正在使用https://github.com/RubaXa/Sortable ,我需要编写一个if / else函数,该函数基本上可以告诉您是否已将正确的图块拖动到正确的目标,如果尚未拖动,则将其反弹回它来自哪里(顺序相同)。

Pretty sure i use this event: Element is dropped into the list from another list 相当确定我使用了此事件:元素从另一个列表拖放到列表中

 onAdd: function (/**Event*/evt) {
    var itemEl = evt.item;  // dragged HTMLElement
    evt.from;  // previous list
    // + indexes from onEnd
    },

First off, is evt a common parameter? 首先,evt是一个通用参数吗? (I am not a coder). (我不是编码员)。

Please find my working code here: https://codepen.io/maevemacn/pen/XMvZjP this does not include the external sortable.min.js file 请在这里找到我的工作代码: https : //codepen.io/maevemacn/pen/XMvZjP这不包括外部sortable.min.js文件

Any help greatly appreciated Maeve 任何帮助都非常感谢Maeve

How about something like this then? 那这样的事情怎么样? This is a minimal implementation of what I believe you're after. 这是我相信您所追求的最低限度的实现。

http://codepen.io/anon/pen/xdGoNe http://codepen.io/anon/pen/xdGoNe

            onMove: function (evt, originalEvent) {
                var textOfItemBeingDragged = evt.dragged.innerText.toLowerCase();
                var destinationIndexOfTarget = evt.related.getAttribute('destination-index');
                var areWeAllowedToDragToHere = allowedMappings[textOfItemBeingDragged] ==
                    destinationIndexOfTarget;
                return areWeAllowedToDragToHere;
            }

onMove does the interesting work - we check whether we're allowed to drop this item into the specific box onMove进行了有趣的工作-我们检查是否允许将此项目放入特定的框中

暂无
暂无

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

相关问题 在异步队列内的函数内进行异步Twitter调用-https://github.com/DeviaVir/zenbot - Async twitter call inside a function that is inside a async queue - https://github.com/DeviaVir/zenbot 在本地运行 https://github.com/akella/webgl-mouseover-effects 代码 - Run https://github.com/akella/webgl-mouseover-effects code locally 无法在meanstack MEANIO上运行localhost:3000,https://github.com/linnovate/mean - cannot run localhost:3000 on meanstack MEANIO, https://github.com/linnovate/mean 如何处理“已弃用,请使用https://github.com/pillarjs/path-to-regexp”消息 - how to deal with “DEPRECATED use https://github.com/pillarjs/path-to-regexp” message Rails 7 无法导入纱线 package (https://github.com/keisto/vanilla-rangeslider) - Rails 7 failing to import yarn package (https://github.com/keisto/vanilla-rangeslider) 如何为Tween.js分配额外的属性(https://github.com/sole/tween.js/) - How to assign extra attributes to Tween.js ( https://github.com/sole/tween.js/ ) 无法使用库https://github.com/hiddentao/linear-algebra运行简单的示例 - Unable to run simple example using library https://github.com/hiddentao/linear-algebra 如何在浏览器中使用“https://github.com/ovvn/dom-to-pdf” - How can I use `https://github.com/ovvn/dom-to-pdf` in a Browser 来自 https://github.com/thread-pond/signature-pad 的 JS 签名板无法在更大的触摸屏笔记本电脑和台式机上工作 - JS signature pad from https://github.com/thread-pond/signature-pad is unable to work on larger touch screens laptops and desktops 在RubaXa'排序中移动表的列 - Moving column of table in RubaXa' sortable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM