If you take a sorted element and start dragging down / sideways of the page - the page will increase indefinitely until the element is released.
How to ban this behavior?
If you take a sorted element and start dragging down / sideways of the page - the page will increase indefinitely until the element is released.
How to ban this behavior?
Jquery ui sortable has such a wonderful property as containment . With it you can limit the movement of the element. In your case there should be an element width and height equal to the size of the screen.
$("#sortable").sortable({ cancel: ".fixed", containment: ".demo" }); $("#sortable").disableSelection(); #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; cursor:move; } #sortable li span { position: absolute; margin-left: -1.3em; } #sortable li.fixed{cursor:default; color:#959595; opacity:0.5;} <link href="https://code.jquery.com/ui/1.12.0/themes/smoothness/jquery-ui.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script> <div class="demo"> <ul id="sortable"> <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-ns"></span>Item 1</li> <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-ns"></span>Item 2</li> <li class="ui-state-default fixed"><span class="ui-icon ui-icon-arrowthick-2-ns"></span>Item 3</li> <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-ns"></span>Item 4</li> <li class="ui-state-default fixed"><span class="ui-icon ui-icon-arrowthick-2-ns"></span>Item 5</li> <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-ns"></span>Item 6</li> <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-ns"></span>Item 7</li> </ul> </div> Source: https://ru.stackoverflow.com/questions/813551/
All Articles