2019-09-12 23:24:39 +08:00
|
|
|
(function (document) {
|
|
|
|
//Usage: $("#id").Drag()
|
|
|
|
//Author: hooyes
|
|
|
|
$.fn.Drag = function (target) {
|
|
|
|
var M = false;
|
|
|
|
var Rx, Ry;
|
|
|
|
var t = $(this);
|
|
|
|
t.mousedown(function (event) {
|
|
|
|
event.stopPropagation();
|
|
|
|
Rx = event.pageX - (parseInt(target.css("left")) || 0);
|
|
|
|
Ry = event.pageY - (parseInt(target.css("top")) || 0);
|
|
|
|
M = true;
|
|
|
|
})
|
|
|
|
.mouseup(function (event) {
|
|
|
|
M = false;
|
2019-09-13 15:52:47 +08:00
|
|
|
//t.fadeTo(20, 1);
|
2019-09-12 23:24:39 +08:00
|
|
|
});
|
|
|
|
$(document).mousemove(function (event) {
|
|
|
|
if (M) {
|
|
|
|
target.css({
|
|
|
|
top: event.pageY - Ry,
|
|
|
|
left: event.pageX - Rx
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})(document);
|