-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
bug + fix : fallback mode + move in owner container #422
Comments
I had a similar problem as you describe, as well having problems moving items between different containers when the items did not have a vertical layout. There seem to be a bug in _ghostInBottom(). When using touch or when native drag and drop is not supported. In these cases a ghost item is appended to the container. The problem is that the _ghostInBottom assumes that the lastElementChild is the last draggable item, but it will actually check against the ghost item. Changing the _ghostInBottom to this fixed the problem while still allowing the item to be dragged into another container:
This method has other problems as well which will manifest when trying to do something else than vertical lists when the container is bigger than its contained items. If the layout is horizontal or like in my example, grid (4xN), the
will fail to detect that I am actually hovering the container. It's not an easy to write one that will fit all use-cases. The one that fixed it for me was:
This one will have the in-between items margin problem though (which is not an issue in my use case) Anyways, just wanted to flag for this and propose to expose this method to be configurable :) |
Thank you Addeventure, you're right, there is something with the _ghostInBottom related to this bug. Unfortunately, no time to investigate this for the moment |
based on your idea, I suggest this fix. function _ghostInBottom(el, evt) {
var lastEl = el.lastElementChild;
if (lastEl===ghostEl) {
lastEl = lastEl.previousElementSibling || ghostEl;
}
var rect = lastEl.getBoundingClientRect();
return (evt.clientY - (rect.top + rect.height) > 5) && lastEl; // min delta
} |
SortableJS#422: fix fallback moves in owner container
SortableJS#422: fix fallback mode moves in owner container
Revert "SortableJS#422: fix fallback mode moves in owner container"
SortableJS#422: fix fallback moves in owner container
Revert "SortableJS#422: fix fallback moves in owner container"
In fallback mode (no native drag and drop support), a ghost item is appended to the parent container causing the _ghostInBottom() to bug when moving elm in owner container.
This is visible in fallback mode only (set forceFallback to true)
see http://jsbin.com/dolojo/edit?html,css,output
possible fix below
The text was updated successfully, but these errors were encountered: