Caching $(document.body) once document is ready. Fixes #10.

This commit is contained in:
vieron
2012-08-03 16:45:49 +02:00
parent c03a11eed8
commit 9987989c8c
+5 -5
View File
@@ -19,7 +19,6 @@
// stop : function(e){}
};
var $body = $(document.body);
var $window = $(window);
@@ -51,6 +50,7 @@
*/
function Draggable(el, options) {
this.options = $.extend({}, defaults, options);
this.$body = $(document.body);
this.$container = $(el);
this.$dragitems = $(this.options.items, this.$container);
this.is_dragging = false;
@@ -164,7 +164,7 @@
this.mouse_init_pos = this.get_mouse_pos(e);
this.offsetY = this.mouse_init_pos.top - this.el_init_pos.top;
$body.on('mousemove.draggable', function(mme){
this.$body.on('mousemove.draggable', function(mme){
var mouse_actual_pos = self.get_mouse_pos(mme);
var diff_x = Math.abs(
@@ -279,9 +279,9 @@
this.$container.on('mousedown.draggable', this.options.items, $.proxy(
this.drag_handler, this));
$body.on('mouseup.draggable', $.proxy(function(e) {
this.$body.on('mouseup.draggable', $.proxy(function(e) {
this.is_dragging = false;
$body.off('mousemove.draggable');
this.$body.off('mousemove.draggable');
if (this.drag_start) {
this.on_dragstop(e);
}
@@ -291,7 +291,7 @@
fn.disable = function(){
this.$container.off('mousedown.draggable');
$body.off('mouseup.draggable');
this.$body.off('mouseup.draggable');
};