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

allow/disallow movement by mouse to left (make sibling) and right (make child) #30

Open
mafar opened this issue Dec 31, 2014 · 4 comments

Comments

@mafar
Copy link

mafar commented Dec 31, 2014

Hi,
I think there should be an option if you want to force that users can make a item child by dragging them right and so on.
This is helpful in situation where you have just groups at root level , max-depth=2 , and you only want user to sort groups or sort items between groups. In such case if user was dropping items fast , most of items would get reverted because users pulled mouse too Right and because of max depth=2, items got reverted. I got lots of complaints because of this from users.

@mafar
Copy link
Author

mafar commented Dec 31, 2014

When there is max depth =2 , why would it even allow some item to be pulled right ? and make it child. Doesnot make sense.

@mafar
Copy link
Author

mafar commented Dec 31, 2014

#31
I solved it by adding 2 options.
allowRightMovement : true/false //whether the item is allowed to move the left by mouse
allowLeftMovement : true/false //whether the item is allowed to move the right by mouse

@mafar
Copy link
Author

mafar commented Dec 31, 2014

ok the betetr fix would be just to wrap else if with `if(!this.beyondMaxLevels){``
at this postion. Now fixes my problem without adding any option

            // mjs - if the item is below a sibling and is moved to the right, make it a child of that sibling
            else if (o.allowRightMovement  
                     &&  previousItem != null
                     && ! previousItem.hasClass(o.disableNestingClass)
                     &&
                        (previousItem.children(o.listType).length && previousItem.children(o.listType).is(':visible')
                         || ! previousItem.children(o.listType).length)
                     && ! (o.protectRoot && this.currentItem[0].parentNode == this.element[0])
                     &&
                        (o.rtl && (this.positionAbs.left + this.helper.outerWidth() < previousItem.offset().left + previousItem.outerWidth() - o.tabSize)
                         || ! o.rtl && (this.positionAbs.left > previousItem.offset().left + o.tabSize))
            ) {

                this._isAllowed(previousItem, level, level+childLevels+1);

                if(!this.beyondMaxLevels){
                    if (!previousItem.children(o.listType).length) {
                        previousItem[0].appendChild(newList);
                        o.isTree && previousItem.removeClass(o.leafClass).addClass(o.branchClass + ' ' + o.expandedClass);
                    }

                    // mjs - if this item is being moved from the top, add it to the top of the list.
                    if (previousTopOffset && (previousTopOffset <= previousItem.offset().top)) {
                        previousItem.children(o.listType).prepend(this.placeholder);
                    }
                    // mjs - otherwise, add it to the bottom of the list.
                    else {
                        previousItem.children(o.listType)[0].appendChild(this.placeholder[0]);
                    }

                    this._trigger("change", event, this._uiHash());
                }

            }

@LrntL
Copy link

LrntL commented Aug 6, 2019

Thanks

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

2 participants