:hover sticks to element on drag and drop

前端 未结 2 813
轻奢々
轻奢々 2021-02-19 18:40

I have simple ol-li construction and want to add drag\'n\'drop to it. Additionaly I want to highlight hover item and dragover item in different colors. But it is an unusual bug

2条回答
  •  礼貌的吻别
    2021-02-19 19:16

    Here is how I solved it. I had to resort to a little bit of JS unfortunately.

    My page has collapsed records that highlight on hover. Clicking the record will expand it and disable the highlighting. Clicking again will re-collapse and resume hovering:

    $(document).on('click', ".container.clickable", function(e){
      var $this = $(this);
      $this.toggleClass('expandable');
      if ($this.hasClass('expandable')) {
        $this.on('mouseenter', function(){
          // workaround to stop a stuck :hover
          $this.addClass('hilitable');
          $this.off('mouseenter');
        })
      } else {
        $this.removeClass('hilitable');
      }
    });
    

提交回复
热议问题