-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Custom offset handler #285
Comments
Renamed the issue. How about the ability to pass in a handler that can be used to calculate the offset? |
I would need this too. I use Dragula inside of a modal and the offset doesn't account for this modal positioning |
@GermainBergeron I added a PR, but it's not passing :( I haven't had a chance to look into why, but I'm using the changes in a project currently |
I forked the repo and applied your changes. The test are green, I don't know what went wrong with travis. @rohmann I can do a new PR if you want, it literally a copy paste of your code |
Go for it! |
I ran into the same issue. One way to get around it, is to simply turn off the css "transform" property of the modal so that the fixed position is not affected by the transformed context. Another way is to compensating for it via custom offset like you do, though I feel it a bit hacky for some reason. |
After applying the patch by rohmann in his pull request, below is the code i used to adjust the offset of boostrap modal. This works for single level modal, i haven't tried with nested modal.
The issue with bootstrap is that, as I explained earlier, it uses transform
Hope this helps someone. I wasted several hours with this. Note: closest method is not supported in some browsers such as IE, you may write your own js to traverse the tree or use jQuery or anything. The purpose of that line of code is to get the modal the element stays in to get its offset to adjust. |
This works fine: cf10a03 |
There are a few cases where I would like
_offsetX
andoffsetY
to be0
rather than the calculated value. This way my element is guaranteed to be placed at the mouse coordinates.Example 1: I have a larger element, and I'm styling
gu-mirror
to make it appear as just an icon as it's being dragged.Example 2: I'm manually starting a drag event, and following up by dispatching a
mousedown
event to force the drag to begin (The mouse is already clicked down from a previous event). Having no offset will allow that element to jump to the mouse position.The text was updated successfully, but these errors were encountered: