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

Prevent rounding bug in LayerDraggable #517

Merged
merged 2 commits into from Jun 15, 2017
Merged

Prevent rounding bug in LayerDraggable #517

merged 2 commits into from Jun 15, 2017

Conversation

daneden
Copy link
Contributor

@daneden daneden commented Jun 13, 2017

A colleague recently discovered a bug that caused draggable layers with constraints to incorrectly animate to a slightly different position than specified. The bug can be reproduced using the following code: https://gist.github.com/daneden/f5a0826168ea9626af3091d5b08c7911

Dragging the layer myCard up causes it to return to position y: 89 instead of y: 90. This PR addresses the issue by using Math.round instead of parseInt to ensure the layer is returned to the correct constraint.

> parseInt(8.999)
  8
> Math.round(8.999)
  9

A colleague recently discovered a bug that caused draggable layers with constraints to incorrectly animate to a slightly different position that specified. The bug can be reproduced using the following code: https://gist.github.com/daneden/f5a0826168ea9626af3091d5b08c7911

Dragging the layer `myCard` up causes it to return to position `y: 89` instead of `y: 90`. This PR addresses the issue by using `Math.round` instead of `parseInt` to ensure the layer is returned to the correct constraint.

```js
> parseInt(8.999)
  9
> Math.round(8.999)
  8
```
@gk3
Copy link
Contributor

gk3 commented Jun 14, 2017

cc @koenbok

@nvh
Copy link
Collaborator

nvh commented Jun 15, 2017

Makes sense to me

@nvh nvh merged commit 0c93b70 into koenbok:master Jun 15, 2017
@daneden daneden deleted the patch-1 branch June 15, 2017 18:08
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

3 participants