This commit is contained in:
张磊 2015-06-21 08:52:23 +08:00
parent c04ed1760c
commit cc7e127217
1 changed files with 1 additions and 9 deletions

View File

@ -27,25 +27,19 @@
this.$dragElement = $(option.dragElement)
this.$moveElement.css("position", "absolute");
this.$dragElement.css("cursor", option.cursor || "move");
this.$dragElement.on("mousedown", this._mousedown.bind(this));
if (this.$moveElement.css("left") === "auto") this.$moveElement.css("left", 0);
if (this.$dragElement.css("top") === "auto") this.$dragElement.css("top", 0);
this._docMove = this._mousemove.bind(this);
this._docUp = this._mouseup.bind(this);
this.stopped = false;
},
_mousedown: function (evt) {
_mousedown: function (evt) {
this.currentPosition.x = evt.pageX;
this.currentPosition.y = evt.pageY;
$(document).on("mousemove", this._docMove);
$(document).on("mouseup", this._docUp);
evt.stopDrag = function () {
this.stopped = true;
}.bind(this);
if (this.option.start) {
@ -68,7 +62,6 @@
this.currentPosition.x = evt.pageX;
this.currentPosition.y = evt.pageY;
evt.preventDefault();
},
_mouseup: function (evt) {
$(document).off("mousemove", this._docMove);
@ -77,7 +70,6 @@
this.option.end(evt);
}
this.stopped = false;
}
})