简体   繁体   English

拖动元素的克隆,并使用可排序的jqueryui将其放在div区域中

[英]clone of dragged element and place it in dragged div area using sortable jqueryui

I am trying to clone the dragged element and put it in the area where the dragged element was present with 0.2 opacity. 我正在尝试克隆拖动的元素,并将其放置在拖动的元素以0.2不透明度存在的区域中。 for some reason its not working perfectly.place holder can move and show the place where to drop the element but the area from where the element was dragged should show the clone with reduced opacity till the element is dropped. 由于某种原因,它不能完美工作。占位符可以移动并显示放置元素的位置,但是从中拖动元素的区域应显示不透明度降低的克隆,直到放置元素为止。

js fiddle: js小提琴:

http://jsfiddle.net/Fj7eN/ http://jsfiddle.net/Fj7eN/

html: 的HTML:

<div id="sortable">
    <div class="one sortableElems">Div 1</div>
    <div class="two sortableElems">Div 2</div>
    <div class="three sortableElems">Div 3</div>
</div>

jquery: jQuery的:

$(function() {      
    $("#sortable").sortable({
        opacity: 0.8,
        cursor:"-webkit-grab",
        placeholder: {
            element: function(item, ui) {
                return item.clone().css({
                    "opacity":"0.2", 
                    "position":"relative"
                });
            },
            update: function() {
                return;
            }
        }
    });
});

Found the answer myself: 自己找到答案:

js fiddle: js小提琴:

http://jsfiddle.net/Fj7eN/5/ http://jsfiddle.net/Fj7eN/5/

jquery: jQuery的:

$(function() {  
    $("#sortable").sortable({
        opacity: 0.8,
        cursor:"-webkit-grab",
        start:function(e,ui){
            $(ui.item[0]).css({"display":"block","opacity":"0.2"});
        },
        helper:"clone",
        placeholder: "placeholder",
        update:function(e,ui){
           $(ui.item[0]).css({"opacity":"1"});
        }
    });
});

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

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