jquery - How to get drag hover event outside the sortable element -
i using jquery sortable short list , it's working need drag hover when drag hover outside sortable element. in below html need drag hover on 'upper' , 'bottom'.
<div class="container"> <div class="upper">upper</div> <ul id="slide"> <li class="slide">slide 1</li> <li class="slide">slide 2</li> <li class="slide">slide 3</li> <li class="slide">slide 4</li> <li class="slide">slide 5</li> </ul> <div class="bottom">bottom</div> </div>
and apply sortable on 'slide'.
$("#slide").sortable({ placeholder: 'slide-placeholder', axis: "y", revert: 150, start: function(e, ui){ placeholderheight = ui.item.outerheight(); ui.placeholder.height(placeholderheight + 15); $('<div class="slide-placeholder-animator" data-height="' + placeholderheight + '"></div>').insertafter(ui.placeholder); }, change: function(event, ui) { ui.placeholder.stop().height(0).animate({ height: ui.item.outerheight() + 15 }, 300); placeholderanimatorheight = parseint($(".slide-placeholder-animator").attr("data-height")); $(".slide-placeholder-animator").stop().height(placeholderanimatorheight + 15).animate({ height: 0 }, 300, function() { $(this).remove(); placeholderheight = ui.item.outerheight(); $('<div class="slide-placeholder-animator" data-height="' + placeholderheight + '"></div>').insertafter(ui.placeholder); }); }, stop: function(e, ui) { $(".slide-placeholder-animator").remove(); } });
css
body { padding: 20px; } #slide { list-style: none; margin: 0; padding: 0; width: 300px; } .slide { padding: 15px; background-color: #2f2f2f; margin: 0 0 15px; text-align: center; color: #fff; border: 2px solid #444; } .slide-placeholder { background: #dadada; position: relative; } .slide-placeholder:after { content: " "; position: absolute; bottom: 0; left: 0; right: 0; height: 15px; background-color: #fff; } .bottom, .upper{ height: 30px; text-align: center; } .container{width:300px;}
it happen when bind droppable events.
$(".upper").droppable({ over: function( event, ui ) { console.log('over'); }, out: function( event, ui ) { console.log('out'); } }); $(".bottom").droppable({ over: function( event, ui ) { console.log('over'); }, out: function( event, ui ) { console.log('out'); } });
Comments
Post a Comment