Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The element's original transform properties are discarded while dragging #92

Open
wugangca opened this issue Jun 23, 2015 · 8 comments
Open
Labels

Comments

@wugangca
Copy link

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,

@desandro
Copy link
Owner

desandro commented Jun 23, 2015

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 desandro added the bug label Jun 23, 2015
@wugangca
Copy link
Author

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

@desandro
Copy link
Owner

sure, let's take a look :)

@peterbe
Copy link

peterbe commented Nov 17, 2015

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.

@dtheb
Copy link

dtheb commented Mar 31, 2016

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

@ethanclevenger91
Copy link

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%);
}

@cstolli
Copy link

cstolli commented Apr 27, 2016

👍 really need this!

@Alecyrus
Copy link

@desandro no considering to fix this??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants