Chodzi mi o to w jaki sposób zrobić blokadę przesuwania elementu jeśli kursor myszy znajdzie się poza wyznaczonym polem?
<html lang="en"> <head> <meta charset="utf-8" /> <link rel="stylesheet" href="css/jquery-ui.css" /> <link rel="stylesheet" href="css/style.css" /> </head> <body> <div class="container-border"> <div class="container"> </div> </div> </body> <script> $(function() { $("#draggable").draggable({ containment: "parent", snap: true, grid: [10, 10] }); }); </script> </html>
*{ -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ -moz-box-sizing: border-box; /* Firefox, other Gecko */ box-sizing: border-box; /* Opera/IE 8+ */ } body{ margin:0; padding:0; font-family: Arial; font-size:12px; width:auto; height:auto; margin: 0 auto 0 auto; background: #fff; padding-top: 10px; color:#333333; } h1, h2, h3, h4, h5, h6, h7, h8, form, input, textarea, select, p{ margin: 0px; padding: 0px; } a{ text-decoration: none; color: #277093; } /*===============================================================================
=================*/ #draggable { width: 200px; height: 30px; } .container-border{ height: 802px; width: 602px; border: 1px solid red; margin: 0 auto 0 auto; } .container{ height: 800px; width: 600px; } .draggable{ border: 1px solid #DDDDDD; position: absolute; } .box { position: absolute; height: 98px; width: 98px; background: #CCF; border: 1px solid #AAD; text-align: center; font-size: 10px; cursor: move; }