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

Fixed using angular2-draggable with a scaled parent elment #39

Merged
merged 1 commit into from
Feb 1, 2018

Conversation

synnottd
Copy link
Contributor

@synnottd synnottd commented Jan 29, 2018

This fixes the problem outlined here: #31.

Note: I fixed for a parent with scaling not the element itself.

I work with the OP and it became necessary for us to get this working.

The issues occurs if there is a CSS transform scale on a parent of the element you want to drag. The errors are that the element is transformed by the unscaled distance, meaning the element effectively is transformed visibly by the distance * scale, meaning the cursor and the element become de-synced. It will also move out of bounds if bounds are set.

I fixed these problems by dividing anything changing AngularDraggableDirective.tempTrans by the scale. I decided the best way to know the scale is to require the user to pass it in as an Input. You could probably use window.getComputedStyle() to work it out, but it seems overkill to do this.

@xieziyu xieziyu merged commit 5e747c7 into xieziyu:master Feb 1, 2018
@xieziyu
Copy link
Owner

xieziyu commented Feb 1, 2018

Great! Thanks for your contribution. I agree with your design.

@xieziyu
Copy link
Owner

xieziyu commented Feb 1, 2018

I tested your changes. It seems the calculation will bring other issues.
So I have to revert that part of your changes.

@synnottd
Copy link
Contributor Author

synnottd commented Feb 1, 2018

Would you mind elaborating? I'm more than happy to fix it.

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

Successfully merging this pull request may close these issues.

None yet

2 participants