简体   繁体   English

如何使用dojo / dnd / Moveable以编程方式开始拖动项目?

[英]How to start dragging an item programmatically using dojo/dnd/Moveable?

I am using dojo/dnd/Moveable in order to make an item draggable. 我正在使用dojo / dnd / Moveable来使项目可拖动。 At the moment using the following script: 目前使用以下脚本:

  • user click the button "make movable", div is now draggable 用户单击按钮“使可移动”,div现在可拖动
  • user has to point and drag on the div in order to start dragging. 用户必须在div上指向并拖动才能开始拖动。

I would need change its behavior in the following way: 我需要通过以下方式更改其行为:

  • user click and keep pressed the button "make movable" 用户单击并按住按钮“使可移动”
  • div is immediately draggable and take the position of the mouse cursor div可立即拖动并占据鼠标光标的位置

I have tried using topic in manager /dnd/start but with no success. 我尝试在管理器 /dnd/start使用主题,但没有成功。

Any ideas how to solve this? 任何想法如何解决这个问题?

http://jsbin.com/cohalorike/1/ http://jsbin.com/cohalorike/1/

require(["dojo/dnd/Moveable", "dojo/dom", "dojo/on", "dojo/domReady!"],
        function (Moveable, dom, on) {

            on(dom.byId('btn'), 'click', function () {
                var dnd = new Moveable(dom.byId("dndOne"));
                on(dnd, "FirstMove", function (event, leftTop) {
                    console.log('FirstMove', leftTop);
                });
                on(dnd, "Move", function (event, leftTop) {
                    console.log('Move', leftTop);
                });
            });
        });

也许您可以改用dojo/dnd/Source

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM