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 draggable position bouncing when draggable is scaled and position is set #150

Merged
merged 2 commits into from
Apr 18, 2019

Conversation

agnitos
Copy link
Contributor

@agnitos agnitos commented Mar 20, 2019

Fixed #149
As i fixed this bug for the 1st time by moving the bouncing check up (see my 1st commit) I just didn't really like how the scaling code was implemented (needed isDragged, and bouncing fix), so i mostly rewrote how its calculated. Now it just divides moved pixels with scale, so if we moved the draggable by 1px and the scale is 0.5 then it will set that we moved 1 / 0.5 = 2px, the only problem is that broke the bounds and i had to divide the moved pixels with the scale, but i would suggest to just set the draggable position to bounding box side, not constantly removing the difference between the two.

As I was testing my fix i came across another bug that this PR fixes. Scale and gridSize doesn't work together.

Previously, current master:
previously
Now, pr:
fixed

As this isn't so small of a fix and I am afraid that i may have broken something (I tried to test as much as possible, dynamically changing scale, checking if draggable position doesn't change), I would like to ask the scale implementer (@rathodsanjay) to check if I didn't break anything for him.

…on is set

-The bouncing happened because there was incorrect position calculation, the position was increased from scale that it was out of bounds and boundsCheck put it back in incorrect position.
-Scale handling now just divides the moved pixels with the scale coef, so if we moved 1px it will pass that we moved 2px, this allowed me to removed the firstDrag variable as it isn't needed anymore and fix for draggable bouncing on first drag. Also this fixed scale working with gridSize, its now working properly.
@xieziyu xieziyu merged commit a8bec27 into xieziyu:master Apr 18, 2019
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.

ngDraggable with scale and position
2 participants