javascript - jQuery mouseleave not firing correctly while dragging -


i have sortable list mouseleave event listener behaving incorrectly.

if move mouse in , out of sortable list, mouseleave fires correctly.

if first click , drag 1 of sortable's children, mouseleave fires incorrectly - sporadically or not @ all.

any ideas?

thanks.

update: occurs mouseout events well.

<style> #sortable { list-style-type: none; margin: 0; padding: 0; float: left; margin-right: 10px; background-color: #ccc; }  #sortable li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 120px; } </style>  <script>   $(function(){     $("#sortable").sortable().disableselection();     $("#sortable").mouseleave(function(){ console.log("mouseleave"); });   });    </script>  <ul id="sortable">   <li class="ui-state-default">item 1</li>   <li class="ui-state-default">item 2</li>   <li class="ui-state-default">item 3</li> </ul> 

update have used following detect when child has been dragged outside of sortable:

$("#sortable li").mousemove(function() {         if ($(this).offset().left > $(this).parent().outerwidth() + $(this).parent().offset().left ||                 $(this).offset().top > $(this).parent().outerheight() + $(this).parent().offset().top  ||                 $(this).offset().left + $(this).outerwidth() < $(this).parent().offset().left  ||                 $(this).offset().top + $(this).outerheight() < $(this).parent().offset().top ){                 console.log("child outside parent");             }     }); 

i'm going make assumption , trying capture event when element visually leaves sortable area. found out, mouseleave , mouseout not best ways because track mouse movement relative dom elements. since dragging these list items never leave unordered list aren't getting results expect.

this should work you:

$("#sortable").sortable().disableselection(); $("#sortable li").mousemove(function() {     if (parseint($(this).css("left")) > $("#sortable").width() ||         parseint($(this).css("top")) > $("#sortable").height()) {         //this when element out of bounds     } }); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -