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

When using bounds, I expect ui.x and ui.y within bounds #200

Closed
romainneutron opened this issue Oct 4, 2016 · 5 comments
Closed

When using bounds, I expect ui.x and ui.y within bounds #200

romainneutron opened this issue Oct 4, 2016 · 5 comments

Comments

@romainneutron
Copy link

This follow up #150

When creating a draggable with bounds, if your mouse pointer goes outside the bounds, the draggable element stays within the bounds.
However, using a event listener on onDrag like this below shows that the ui.x property is the one of the pointer, not the one of the draggable (ie : the ui.x continues to be updated even if I'm outside of the bounds)

    onDrag = (e, ui) => {
        console.log(ui.x);
    }
@otbe
Copy link

otbe commented Oct 21, 2016

Definitely surprising for me too. Have to build some custom logic around to get the correct behavior.

@louh
Copy link

louh commented Dec 1, 2016

Same. I essentially have to do this:

onDrag = (e, ui) => {
  const boundingBox = this.refElement.getBoundingClientRect();
  let actualX = ui.x;
  let actualY = ui.y;

  if (ui.x < boundingBox.left) {
    actualX = boundingBox.left;
  } else if (ui.x > boundingBox.left + boundingBox.width) {
    actualX = boundingBox.left + boundingBox.width;
  }

  // Do the same for ui.y
  // return actualX and actualY for use, rather than the original `ui` object
}

@ioRekz
Copy link

ioRekz commented Dec 30, 2016

Was surprise as well

@STRML
Copy link
Collaborator

STRML commented Mar 6, 2017

Ref: #226

@STRML STRML closed this as completed Mar 6, 2017
@STRML STRML reopened this Mar 6, 2017
@STRML
Copy link
Collaborator

STRML commented Aug 21, 2017

Fixed in 55f701e

@STRML STRML closed this as completed Aug 21, 2017
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

No branches or pull requests

5 participants