javascript - Jquery ui sortable doesn't sort on half-top-height drag -
solved: containment: $("#sortable").parent().parent();
update: here video explanation this.
i don't know how ask question, don't know how works neither need little here:
when drag second item list , lets item height 50px, when click , drag 0-25px top bottom on item drag first place, first 1 move down, if click , drag 26-50px top bottom on item , try move on first place first item doesn't go down.
now guessing works mouse position , half item height if mouse position on not dragging item less 50% item height moves down, otherwise doesn't move.
how can change in way maybe lock dragging item mouse on 50% top position or ever clicked , moved on element move down?
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jquery ui sortable - default functionality</title> <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <link rel="stylesheet" href="https://jqueryui.com/resources/demos/style.css"> <style> #sortable { list-style-type: none; margin: 0; padding: 0; width: 60%; } #sortable li { margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; font-size: 1.4em; height: 18px; } #sortable li span { position: absolute; margin-left: -1.3em; } div{ width: 60%; height: auto; padding: 20px 0; background: red; } </style> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script> $( function() { $( "#sortable" ).sortable({ containment: $("#sortable").parent().parent(), update: function(){ alert('dropped!'); } }); $( "#sortable" ).disableselection(); } ); </script> </head> <body> <div> <ul id="sortable"> <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>item 1</li> <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>item 2</li> <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>item 3</li> <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>item 4</li> <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>item 5</li> <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>item 6</li> <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>item 7</li> </ul> </body> </html>
when drag little 'up down' arrow works every time. try editing target or parent settings.
Comments
Post a Comment