mouse: cleanup

This commit is contained in:
Scott González 2008-05-28 14:02:56 +00:00
parent 1f360d7d40
commit dd096c1e95

View File

@ -173,6 +173,8 @@
this.started = false; this.started = false;
}, },
// TODO: make sure destroying one instance of mouse doesn't mess with
// other instances of mouse
mouseDestroy: function() { mouseDestroy: function() {
this.element.unbind('.mouse'); this.element.unbind('.mouse');
@ -182,10 +184,8 @@
}, },
mouseDown: function(e) { mouseDown: function(e) {
// we may have missed mouseup (out of window) // we may have missed mouseup (out of window)
(this._mouseStarted (this._mouseStarted && this.mouseUp(e));
&& this.mouseUp(e));
this._mouseDownEvent = e; this._mouseDownEvent = e;
@ -196,7 +196,7 @@
return true; return true;
} }
this._mouseDelayMet = (this.options.delay == 0); this._mouseDelayMet = !this.options.delay;
if (!this._mouseDelayMet) { if (!this._mouseDelayMet) {
this._mouseDelayTimer = setTimeout(function() { this._mouseDelayTimer = setTimeout(function() {
self._mouseDelayMet = true; self._mouseDelayMet = true;
@ -206,10 +206,10 @@
// these delegates are required to keep context // these delegates are required to keep context
this._mouseMoveDelegate = function(e) { this._mouseMoveDelegate = function(e) {
return self.mouseMove(e); return self.mouseMove(e);
} };
this._mouseUpDelegate = function(e) { this._mouseUpDelegate = function(e) {
return self.mouseUp(e); return self.mouseUp(e);
} };
$(document) $(document)
.bind('mousemove.mouse', this._mouseMoveDelegate) .bind('mousemove.mouse', this._mouseMoveDelegate)
.bind('mouseup.mouse', this._mouseUpDelegate); .bind('mouseup.mouse', this._mouseUpDelegate);
@ -218,7 +218,6 @@
}, },
mouseMove: function(e) { mouseMove: function(e) {
// IE mouseup check - mouseup happened when mouse was out of window // IE mouseup check - mouseup happened when mouse was out of window
if ($.browser.msie && !e.button) { if ($.browser.msie && !e.button) {
return this.mouseUp(e); return this.mouseUp(e);
@ -239,7 +238,6 @@
}, },
mouseUp: function(e) { mouseUp: function(e) {
$(document) $(document)
.unbind('mousemove.mouse', this._mouseMoveDelegate) .unbind('mousemove.mouse', this._mouseMoveDelegate)
.unbind('mouseup.mouse', this._mouseUpDelegate); .unbind('mouseup.mouse', this._mouseUpDelegate);