Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Sortable: Calculating item distance and direction using a more robust al... #715

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

zhizhangchen commented Aug 20, 2012

...gorithm to better support sorting among embeded sortables

Use the item with lowest distance bettween the mouse pointer and
each of its borders to rearrange, the direction of which is
determined by the mouse postion relative to the item, with the
exception when the mouse pointer intersects with the item or
distance is zero, in which case mouse moving direction is used.
Also we use this algorithm to rearrange even when currentContainer
is not changed to override the defective rearranging in _mouseDrag

Owner

scottgonzalez commented Aug 20, 2012

Can you provide a demo that shows the improvement?

Contributor

zhizhangchen commented Sep 12, 2012

Following are the problem examples and solutions provided by this PR:

Problem 1: http://jsfiddle.net/Zvvpt/15/

  1. drag the first item and move slowly down, when getting to the bottom of the sortable, the placeholder moves to the top of the sortable
  2. drag the second item and move slowly down, the placeholder doesn't move until the item is dragged out of the sortable, where the placeholder jumps quickly to the bottom of the sortable and then goes to the middle again

Solution: http://jsfiddle.net/kM4dR/2/

Problems 2: http://jsfiddle.net/6bsGx/3/

  1. Click near the bottom of an item and move downwards, notice that the item can't be dragged out of the inner sortable
  2. Click near the top of an item and move upward, notice that the item can't be dragged out of the inner sortable
    Solution: http://jsfiddle.net/6bsGx/6/

Problems 3: http://jsfiddle.net/k4nn3/3/

  1. drag an item down, notice that it's hard to put the item between the two inner sortables. If you clicked the top of an item and drag it down , it can be put between the inner sortables, but you can never make it there when moving upwards.
    Solution: http://jsfiddle.net/k4nn3/5/
@zhizhangchen zhizhangchen Sortable: Calculating item distance and direction using a more robust…
… algorithm to better support sorting among nested sortables

Use the item which has the least distance bettween the mouse
pointer and one of its borders to rearrange, with direction being
determined by the nearest border.
Also we use this algorithm to rearrange even when currentContainer
is not changed to override the defective rearrangment in
_mouseDrag
a4b33bd
Owner

scottgonzalez commented Oct 10, 2012

Thanks, landed in bae06d2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment