Skip to content

During handle dragging, how to limit the dragging area? #631

Answered by mikke89
mplucinski asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there! And welcome :)

It's an excellent question. I think this should be a common enough situation, ideally we would have a built-in way to achieve these constraints that you outline. We don't really have that right now.

The handle element moves the target using the left and top properties, as it looks like you've discovered. And it sets them just before issuing the handledrag call. So based on that, the code you posted should work in principle. I think one possible issue here, is that the absolute position is not immediately updated, it's only done so after a call to update. I think you would get a more correct x-position if you read the left property directly. Another alternative is …

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@mplucinski
Comment options

@mikke89
Comment options

Answer selected by mplucinski
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants