draggabilly icon indicating copy to clipboard operation
draggabilly copied to clipboard

The element's original transform properties are discarded while dragging

Open wugangca opened this issue 9 years ago • 8 comments

In the "positionDrag" function, it replace the transform style with only translate(...) and in the "dragEnd" and "destroy" functions, it empties the transform style. If the element previously has some transform styles, e.g. rotate, scale, they will be lost. Please update the code like

In positionDrag, keep the original transform styles except translate: var transform = this.element.style[ transformProperty ]; transform = transform.replace(/translate(3d)?(.*)/, ''); this.element.style[ transformProperty ] = transform + translate( this.dragPoint.x, this.dragPoint.y );

After drag, keep the original transform styles except translate

var transform = this.element.style[ transformProperty ];
transform = transform.replace(/translate(3d)?\(.*\)/, '');
this.element.style[ transformProperty ] = transform;

Thanks,

wugangca avatar Jun 23 '15 21:06 wugangca

Thanks for reporting this issue. It's certainly a bug, but hasn't been too big of an issue so far.

Add a 👍 reaction to this issue if you would like to see this feature added. Do not add +1 comments — They will be deleted.

desandro avatar Jun 23 '15 21:06 desandro

I have the fix for this issue, and would like to push my fix?

wugangca avatar Jun 25 '15 22:06 wugangca

sure, let's take a look :)

desandro avatar Jun 26 '15 02:06 desandro

I tried it out. It seems to work. However, what doesn't work is to mix this with rotation. My element looks like this:

.thing {
    transform: rotate(270deg);
}

Whilst it's being dragged around, the combined CSS becomes:

transform: rotate(270deg) translate3d(-5px, 2px, 0px)

...etc.

So the code does that it does but the dragging around of it is nuts. It just doesn't appear to work.

peterbe avatar Nov 17 '15 17:11 peterbe

is this implemented yet?? i need this feature to implement scaling/zoom effect :cry:

dtheb avatar Mar 31 '16 00:03 dtheb

Related (perhaps) - on my implementation, when I click on an element with transform, the element immediately gets a left:9px that isn't removed after dragging. That gets added to on each successive drag, so it moves more and more left.

Script:

$('.draggable').each(function() {
    var draggableElem = $(this)[0];
    var draggie = new Draggabilly(draggableElem, {
      axis:'y',
      containment:true
    });
    draggies.push(draggie);
  })

Styles:

.draggable {
    width:25px;
    height:25px;
    border-radius:50%;
    //its width is larger than its container, so this centers it horizontally and vertically
    position:absolute;
    left:50%;
    top:50%;
    transform:translateX(-50%) translateY(-50%);
}

ethanclevenger91 avatar Apr 20 '16 18:04 ethanclevenger91

👍 really need this!

cstolli avatar Apr 27 '16 22:04 cstolli

@desandro no considering to fix this??

Alecyrus avatar Mar 12 '19 07:03 Alecyrus