Sortable icon indicating copy to clipboard operation
Sortable copied to clipboard

Detect "hover" on parent container

Open Ydalb opened this issue 9 years ago • 2 comments

Hello,

I have two list, and i'm moving elements from a list to another.

I'm trying to add a "hover" effect on the list (parent) I'm hovering, but i'm stuck. The jQuery bind works when I'm not moving element, but once I'm moving one, it no longer works.

Here is an example : http://jsbin.com/goqejacuga/edit?html,css,js,output

Tested on Chrome & Safari.

Any advice ?

Ydalb avatar Jun 01 '17 16:06 Ydalb

not sure that this is the most efficient, but it appears to work for me.

I cloned your jsbin, hopefully this link works: http://jsbin.com/zigihanami/1/edit?html,css,js,console,output

if not, all I did was:

  1. add a class called "list" to all of your ul elements so that we can identify them easily. I also added a third list, just for testing.
 <ul class="list" id="child-1">
        <li id="num1">item 111</li>
        <li id="num2">item 222</li>
        <li id="num3">item 333</li>
        <li id="num4">item 444</li>
      </ul>
      <ul class="list" id="child-2">
        <li>item AAA</li>
        <li>item BBB</li>
        <li>item CCC</li>
      </ul>
        <ul class="list" id="child-3">
        <li>item a1</li>
        <li>item b2</li>
        <li>itemc3</li>
      </ul>
  1. use the "onMove" sortable event to identify each list, remove the 'hover' class, and then use the evt.to to identify the list we are hovering over and apply the 'hover' class

var opts = {
  group:"child",
  onMove: function (evt) {
    $(".list").removeClass('hover');
    $(evt.to).addClass('hover');
  }
}

aintJoshinya avatar Jun 01 '17 17:06 aintJoshinya

Thank you @aintJoshinya :D

Ydalb avatar Jun 01 '17 21:06 Ydalb