views:

22

answers:

0

I have a select and drag function. Basically you can select 3 elements and drag them together.

The problem is in Chrome. If one element have a "-webkit-transform: rotate" propriety the whole span jumps up. Its strange because it forks fine in Firefox.

You can see an working example at: http://jsfiddle.net/K2EX9/4/ just give it a try in Chrome, select with the mouse the 3 elements and drag them.

Here is the code:

$('#selectable1').bind('dragSetup', function() {

  var selected = $([]), offset = {top:0, left:0};

    $('#selectable1 span.drag').draggable({
                start: function(ev, ui) {
                $(this).is("#selectable1 span.ui-selected") || $("#selectable1 span.ui-selected").removeClass("ui-selected");
                selected = $("#selectable1 span.ui-selected").each(function() {
                var el = $(this);
                el.data("offset", el.offset());

                });

                offset = $(this).offset();

            },

            drag: function(ev, ui) {

                var dt = ui.position.top - offset.top, dl = ui.position.left - offset.left;

                selected.not(this).each(function() {
                    var el = $(this), off = el.data("offset");
                    el.css({top: off.top + dt, left: off.left + dl});
                });
            },
    });

});

Thank you.