在滚动 window/area 中没有跳跃 drag/resize 对话框?
No jumping drag/resize Dialog in scrolled window/area?
如何正常调整大小和拖动 UI 滚动对话框 window/area?
top/left 修正对话框真的有必要吗? (如何校正两者都有效的坐标)
修复对话框怎么样?那么有什么变化?
这是 jQuery-UI 错误吗?
$("#myD").dialog({
title: "Dialog TITLE",
modal: true,
resizable: true,
draggable: true,
closeOnEscape: true,
width: 400,
height: 300,
position: { my: "left top", at: "left+350 top+200"},
buttons: buttons,
open: function(event, ui) {
// Set UI-Dialog fixed
$(this).parent().css("position","fixed");
/*
var top = parseInt($(this).parent().css("top"));
var left = parseInt($(this).parent().css("left"));
var scrollTop = $(document).scrollTop();
var scrollLeft = $(document).scrollLeft();
var newTop = top - scrollTop;
var newLeft = left - scrollLeft;
$(this).parent().css("top",newTop+"px");
$(this).parent().css("left",newLeft+"px");
*/
}
});
我看到了一些这样的问题,但是没有
找到满意的答案。
我正在使用 jQuery 1.9.1 和 jQuery UI 1.10.4
谢谢
jsfiddle example (try resize, drag, resize again, etc.)
编辑:找到相关的 jQuery UI Bug
我找到了解决方案。使用以下代码,我们可以修复 UI 1.10.4 中的此错误(覆盖 _mouseStart 函数):
/**
* jQuery-UI-Dialog-Resize bugfix for UI 1.10.4
*/
(function() {
function num(v) {
return parseInt(v, 10) || 0;
}
$.widget( "ui.resizable", $.ui.resizable, {
_mouseStart: function(event) {
console.log( "custom _mouseStart" );
var curleft, curtop, cursor,
o = this.options,
iniPos = this.element.position(),
el = this.element;
this.resizing = true;
// bugfix for http://dev.jquery.com/ticket/1749
if ( (/absolute/).test( el.css("position") ) ) {
el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
} else if ( (/fixed/).test( el.css("position") ) ) {
console.log( "bugfix" );
} else if (el.is(".ui-draggable")) {
el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
}
this._renderProxy();
curleft = num(this.helper.css("left"));
curtop = num(this.helper.css("top"));
if (o.containment) {
curleft += $(o.containment).scrollLeft() || 0;
curtop += $(o.containment).scrollTop() || 0;
}
//Store needed variables
this.offset = this.helper.offset();
this.position = { left: curleft, top: curtop };
this.size = this._helper ? { width: this.helper.width(), height: this.helper.height() } : { width: el.width(), height: el.height() };
this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
this.originalPosition = { left: curleft, top: curtop };
this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
this.originalMousePosition = { left: event.pageX, top: event.pageY };
//Aspect Ratio
this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
cursor = $(".ui-resizable-" + this.axis).css("cursor");
$("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
el.addClass("ui-resizable-resizing");
this._propagate("start", event);
return true;
}
});
})();
完成!
PS。 jsfiddle 示例已更新
如何正常调整大小和拖动 UI 滚动对话框 window/area?
top/left 修正对话框真的有必要吗? (如何校正两者都有效的坐标)
修复对话框怎么样?那么有什么变化?
这是 jQuery-UI 错误吗?
$("#myD").dialog({
title: "Dialog TITLE",
modal: true,
resizable: true,
draggable: true,
closeOnEscape: true,
width: 400,
height: 300,
position: { my: "left top", at: "left+350 top+200"},
buttons: buttons,
open: function(event, ui) {
// Set UI-Dialog fixed
$(this).parent().css("position","fixed");
/*
var top = parseInt($(this).parent().css("top"));
var left = parseInt($(this).parent().css("left"));
var scrollTop = $(document).scrollTop();
var scrollLeft = $(document).scrollLeft();
var newTop = top - scrollTop;
var newLeft = left - scrollLeft;
$(this).parent().css("top",newTop+"px");
$(this).parent().css("left",newLeft+"px");
*/
}
});
我看到了一些这样的问题,但是没有 找到满意的答案。
我正在使用 jQuery 1.9.1 和 jQuery UI 1.10.4
谢谢
jsfiddle example (try resize, drag, resize again, etc.)
编辑:找到相关的 jQuery UI Bug
我找到了解决方案。使用以下代码,我们可以修复 UI 1.10.4 中的此错误(覆盖 _mouseStart 函数):
/**
* jQuery-UI-Dialog-Resize bugfix for UI 1.10.4
*/
(function() {
function num(v) {
return parseInt(v, 10) || 0;
}
$.widget( "ui.resizable", $.ui.resizable, {
_mouseStart: function(event) {
console.log( "custom _mouseStart" );
var curleft, curtop, cursor,
o = this.options,
iniPos = this.element.position(),
el = this.element;
this.resizing = true;
// bugfix for http://dev.jquery.com/ticket/1749
if ( (/absolute/).test( el.css("position") ) ) {
el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
} else if ( (/fixed/).test( el.css("position") ) ) {
console.log( "bugfix" );
} else if (el.is(".ui-draggable")) {
el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
}
this._renderProxy();
curleft = num(this.helper.css("left"));
curtop = num(this.helper.css("top"));
if (o.containment) {
curleft += $(o.containment).scrollLeft() || 0;
curtop += $(o.containment).scrollTop() || 0;
}
//Store needed variables
this.offset = this.helper.offset();
this.position = { left: curleft, top: curtop };
this.size = this._helper ? { width: this.helper.width(), height: this.helper.height() } : { width: el.width(), height: el.height() };
this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
this.originalPosition = { left: curleft, top: curtop };
this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
this.originalMousePosition = { left: event.pageX, top: event.pageY };
//Aspect Ratio
this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
cursor = $(".ui-resizable-" + this.axis).css("cursor");
$("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
el.addClass("ui-resizable-resizing");
this._propagate("start", event);
return true;
}
});
})();
完成!
PS。 jsfiddle 示例已更新