(function ($)
{
var methods = {
init:
function (options)
{
options.obj
= this;
options.obj.children().bind(
"mousedown", options, methods.ondrag).unbind("click").css({ cursor: "move" });
},
destroy:
function (options)
{
this.children().unbind("mousedown").css({ cursor: "hand" }); ;
if (options && options.fn)
{
this.children().bind("click", options.fn);
}
},
ondrag:
function (event)
{
this.setCapture();
var $this = $(this);
$
this.css({ "z-index": setdate.topindex, "filter": "alpha(opacity=50);-moz-opacity: 0.5;opacity: 0.5;" });
setdate.topindex
++;
setdate.mouseOffest
= { top: event.offsetY, left: event.offsetX };
$
this.bind("mousemove.drag", event.data, methods.onmove);
$
this.bind("mouseup.drag", event.data, methods.ondrop);
},
onmove:
function (event)
{
var $this = $(this);
$
this.offset({ top: event.clientY - setdate.mouseOffest.top, left: event.clientX - setdate.mouseOffest.left });
},
ondrop:
function (event)
{
var $this = $(this);
$
this.unbind(".drag").css({ "filter": "alpha(opacity=100);-moz-opacity: 1;opacity: 1;" });
this.releaseCapture();
},
checkpos:
function (event)
{

}
};
var setdate = { topindex: 1 };
$.fn.DragDropAuto
= function (method)
{
if (this.length == 0) return;
if (methods[method])
{
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
}
else if (typeof method === 'object' || !method)
{
return methods.init.apply(this, arguments);
}
else { $.error('Method ' + method + ' does not exist on jQuery.DragDropAuto'); }
};
})(jQuery);

相关文章:

  • 2022-01-18
  • 2021-06-21
  • 2021-12-12
  • 2022-12-23
  • 2021-08-24
  • 2021-12-25
  • 2021-11-22
  • 2021-07-30
猜你喜欢
  • 2021-09-14
  • 2022-12-23
  • 2022-01-27
  • 2022-02-18
  • 2022-12-23
  • 2021-05-10
相关资源
相似解决方案