0

I want to constrain a controller within an area of a circle with jquery-ui's draggable widget. I write some codes like this:

<!doctype html>
<html lang="en">
  <head>
  <meta charset="utf-8">
  <title></title>
  <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
  <script src="http://code.jquery.com/ui/1.11.3/jquery-ui.js"></script>
  <style>
    .draggable {
        width: 80px;
        height: 80px;
        border: thin solid #000000;
        border-radius: 40px;
        position: relative;
        top: 110px;
        left: 110px;
        background-color: #000000;
    }
    .containment-wrapper {
        height: 300px;
        width: 300px;
        border: thin solid #000000;
        border-radius: 150px;
    }
    </style>
    </head>
    <body>
        <div class="containment-wrapper">
            <div id="draggable" class="draggable"></div>
        </div>
    </body>
    <script>
    $( "#draggable" ).draggable({ containment: "parent" });
    </script>
</html>

The path which the black circle can go along is actually a rectangle, even the appearance of the wrapper div is a circle.

How to correct this to fit my purpose?

Douglas Su
  • 3,214
  • 7
  • 29
  • 58

0 Answers0