Created
September 18, 2013 09:07
-
-
Save matherton/6606557 to your computer and use it in GitHub Desktop.
Draggable jQuery Div with callback functions (comments included)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>Dragable Demo</title> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> | |
| <script src="ui.js"></script> | |
| <style> | |
| .item { | |
| height: 180px; | |
| width: 180px; | |
| border: 3px solid grey; | |
| background-color: #ffffff; | |
| } | |
| .movablecontainer { | |
| height:800px; | |
| width: 800px; | |
| background-color: #000000; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="movablecontainer"> | |
| <div class="item" id="movable"> | |
| <p>This div is moveable</p> | |
| </div> | |
| <div id="event" style="color:white;"></div> | |
| </div> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function(){ | |
| $("#movable").draggable({ containment: 'parent', cursor: 'pointer', opacity: 0.60, grid: [220, 220], revert: true, | |
| /* call back functions allow events to occur the parent function is in opereation */ | |
| start: function () { | |
| $('#event').text('dragging started'); | |
| }, | |
| drag: function () { | |
| $('#event').text('dragging'); | |
| }, | |
| stop: function () { | |
| $('#event').text('draggin finished'); | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment