function dragWin( opt ){
var _options = $.extend({
tit : $('.ui-dialog-titlebar'),
win :$('.ui-dialog'),
dom : $('html')
},opt)
var clicked = "Nope.";
var mausx = "0";
var mausy = "0";
var winx = "0";
var winy = "0";
var difx = mausx - winx;
var dify = mausy - winy;
_options.dom.mousemove(function (event) {
mausx = event.pageX;
mausy = event.pageY;
if(('.ui-dialog') === undefined){
return
}
winx = _options.win.offset().left;
winy = _options.win.offset().top;
if (clicked == "Nope.") {
difx = mausx - winx;
dify = mausy - winy;
}
var newx = event.pageX - difx - _options.win.css("marginLeft").replace('px', '');
var newy = event.pageY - dify - _options.win.css("marginTop").replace('px', '');
_options.win.css({ top: newy, left: newx });
});
_options.tit.mousedown(function (event) {
clicked = "Yeah.";
});
_options.dom.mouseup(function (event) {
clicked = "Nope.";
});
}
jquery 实现弹框拖拽
最新推荐文章于 2024-02-05 11:29:35 发布