Created
December 11, 2011 12:54
-
-
Save vladtsf/1460455 to your computer and use it in GitHub Desktop.
How to create simple draggable control with Vivid Framework
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <!-- jQuery --> | |
| <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script> | |
| <!-- Framework --> | |
| <script type="text/javascript" src="../bin/vivid.js"></script> | |
| <script type="text/javascript" src="./draggable.js"></script> | |
| <script type="text/javascript"> | |
| jQuery(document).ready(function($) { | |
| $('#draggable').draggable() | |
| }); | |
| </script> | |
| <style type="text/css"> | |
| #draggable { | |
| width: 300px; | |
| height: 300px; | |
| background: black; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div id="draggable"> </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
| (function($, undefined) { | |
| var Vivid = $.Vivid; | |
| var Draggable = function($context) { | |
| this | |
| .init($context) | |
| .makeDraggable(); | |
| }; | |
| Draggable.prototype = Vivid.Control(); | |
| $.fn.draggable = function(config) { | |
| this.each(function(i, e) { | |
| var $e = $(e); | |
| if(!$e.data('draggable')) { | |
| $e.data('draggable', new Draggable($e, config)); | |
| } | |
| }); | |
| return this; | |
| }; | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment