jquery可调整大小-是否有机会了解div的大小是比当前大小大还是小
使用jquery'resizeable',我想调整一个div的大小。This.outerDiv还有一个.innerDiv 我想实现的是:当用户调整外部div的大小时,我想计算内部div的高度(我不能给内部div提供100%的高度) 我可以像这样获得新的高度:jquery可调整大小-是否有机会了解div的大小是比当前大小大还是小,jquery,jquery-ui-resizable,Jquery,Jquery Ui Resizable,使用jquery'resizeable',我想调整一个div的大小。This.outerDiv还有一个.innerDiv 我想实现的是:当用户调整外部div的大小时,我想计算内部div的高度(我不能给内部div提供100%的高度) 我可以像这样获得新的高度: resize: function( event, ui ) { var currentHeight = $('.table-container').height(); $('.table-c
resize: function( event, ui ) {
var currentHeight = $('.table-container').height();
$('.table-container').height(currentHeight+1);
}
但当我将div调整为更小的大小时,我希望
resize: function( event, ui ) {
var currentHeight = $('.table-container').height();
$('.table-container').height(currentHeight-1);
}
我不确定,我如何才能得到这样的条件,如果向上调整大小,大小应该更小(高度应该是-1),如果向下调整,大小应该更大(高度应该是+1)
有人能提供一些线索,怎么做吗?我相信下面这样的函数可以解决您的问题。注意信号量和问号操作符:
function handleResizeSignum(context) {
var previousHeight;
var green = true;
function refreshPreviousHeight(h) {
previousHeight = h;
}
context.resize(function() {
if (!green) return;
green = false;
refreshPreviousHeight($(this).height($(this).height() + ($(this).height() >= previousHeight) ? 1 : -1).height());
green = true;
});
}
这个解决方案帮助我:
$('.modal-content-objectProperty').resizable({
minHeight: 385,
minWidth: 600,
maxHeight: 600,
maxWidth: 1050,
alsoResize:".modal-content-objectProperty .react-bs-table-container, .modal-content-objectProperty .table-container",
resize: function( event, ui ) {$('.modal-content-objectProperty').height('auto');}
});
谢谢@Lajos的回答。。不知何故,我通过“alsoResize”选项来管理它。这在我的场景中非常有效。。无论如何,谢谢你的时间和支持solution@ShrutiJog,不客气。尽管如此,如果你已经找到了你问题的答案,我还是希望你把它贴出来,以帮助其他有类似问题的人。