Skip to content

Instantly share code, notes, and snippets.

@vladtsf
Created December 11, 2011 12:54
Show Gist options
  • Save vladtsf/1460455 to your computer and use it in GitHub Desktop.
Save vladtsf/1460455 to your computer and use it in GitHub Desktop.
How to create simple draggable control with Vivid Framework
<!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">&nbsp;</div>
</body>
</html>
(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