camohub / jquery-sortable-lists

jQuery plugin to sorting lists also the tree structures.
MIT License
209 stars 60 forks source link

[Up] Opener position #63

Closed dutom007 closed 3 years ago

dutom007 commented 3 years ago

For info :

On my config (in flex li) opener appear at the end if I move item on nexw submenu.

I change :

if ( hintWrapperNode.length )
{
        hintWrapperNode.prev( 'div' ).append( opener.clone( true ) );
}

by

if ( hintWrapperNode.length )
{
    if( setting.opener.position == "after" )
        hintWrapperNode.prev( 'div' ).append( opener.clone( true ) );
    else
        hintWrapperNode.prev( 'div' ).prepend( opener.clone( true ) );
}

And add option open.position on setting

camohub commented 3 years ago

Why did you do it? You can control the position by css e.g. position absolute. This way options object and the code become more and more complicated.

dutom007 commented 3 years ago

Hi (too),

I use complex <li> with flex rules.

When I load your module, the opener are the first block in my <li>. If I move and create a sublist the opener are appending and by default the "minus" appear at the end.

camohub commented 3 years ago

I dont understand how flex can disable position absolute. Can you make an example on jsfiddle?

dutom007 commented 3 years ago

Here an exemple of my li :

<li id="541" class="s-l-closed">
        <div class="contener"><span class="s-l-opener" style="float: left; display: inline-block; background-position: center center; background-repeat: no-repeat;"><i class="fa fa-plus" aria-hidden="true"></i></span>
            <i class="moving fad fa-arrows" aria-hidden="true"></i>
            <div class="clickable allSize">
                <a class="loadOnSidebar type_invisible" data-url="mine">Auto Created <i class="fad fa-pencil onlyHover fa-edit" aria-hidden="true"></i></a>
            </div>
            <div class="clickable">
                <a class="loadOnSidebar" data-url="mine" title="Ajouter un menu"><i class="fal fa-plus-square" aria-hidden="true"></i></a>
            </div>
        </div>
    <ul style="display: none;">
        SUBLIST
    </ul>
</li>

Float element are ignore if parent is flex contener

camohub commented 3 years ago

This does not work?

.contener {
    position: relative;
}

.s-l-opener {
    position: absolute;
    left: 0;
    top: 0;
}
dutom007 commented 3 years ago

Of course, it's work, but must force me to configure margin or padding for other element (or contener) to prevent layering.

With my option, it's automatic.

I use your (great) plugin on multiple page of my admin, sometime I want the "plus/minus" at the end, sometime at the beginning. With my parameter, no need to use CSS rules on contener

camohub commented 3 years ago

As I wrote in the first comment. This way options object and the code become more and more complicated. It can have impact to the speed. Sorry css is the right clean way.

dutom007 commented 3 years ago

ok ;)