Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 相对定位div上的pep.js_Javascript_Jquery_Css_Drag And Drop - Fatal编程技术网

Javascript 相对定位div上的pep.js

Javascript 相对定位div上的pep.js,javascript,jquery,css,drag-and-drop,Javascript,Jquery,Css,Drag And Drop,我正在使用pep.js,它允许我自由拖放一些DIV 它非常适合绝对定位的DIV,因为它在应用pep.js的DIV中添加了“position:absolute;”as style=“(…)” 但是,当我想定位DIV的relative时,pep.js会将其样式覆盖为“:absolute” 我想要的方式是: 应用pep.js时会发生什么情况: 这是我的pep.js呼叫: $( ".drag" ).pep({ start: function(e,a) { a.$el.addC

我正在使用pep.js,它允许我自由拖放一些DIV

它非常适合绝对定位的DIV,因为它在应用pep.js的DIV中添加了“position:absolute;”as style=“(…)”

但是,当我想定位DIV的relative时,pep.js会将其样式覆盖为“:absolute”

我想要的方式是:

应用pep.js时会发生什么情况:

这是我的pep.js呼叫:

$( ".drag" ).pep({


 start: function(e,a) {
        a.$el.addClass('color');
        a.$el.next(".text").fadeIn("slow");


    },
stop: function(e, a) {
        a.$el.removeClass('color');
        a.$el.next(".text").fadeOut("slow");
    }
我试图将.pep函数包装成.mousedown函数,使其仅在单击DIV时工作——但我无法完全实现我想要的:在这种情况下,我需要单击两次以获得拖动

有人知道我如何编写脚本来保持我的相对位置……或者一直保持到pep.js开始工作(onmousedown)吗

我查看了github中的文档,但没有找到可以帮助我的东西(或者没有正确理解,我是新手)

谢谢你的帮助

更新

解决了!请参阅我的JSFIDLE:

我找到了一种使用GreenSock提供的ThrowPropsPlugin.min.js的方法,但不幸的是,它是免费使用的……有没有可能使用pep.js?同样的问题。切换回jQueryUI我想。。。