JQueryUI - 可调整大小的句柄可以在拖动时释放

时间:2012-04-30 14:06:40

标签: jquery jquery-ui resize

我有一个jquery ui可调整大小的处理程序,它在Web应用程序中往往很慢。可以慢慢地拖动它并且它不会松开,但是如果它从手柄上脱落,它“松开”并停止拖动。

$footer.resizable({ // Footer UI resize
    handles: 'n',
    maxHeight: footerHeight,
    minHeight: minFooterHeight - 5,
    stop: function () { // When user has stopped resizing

    $footer.css({ // reset footer width and top position
        'width': '100%',
        'top': 'auto'
    });

    $footerAndStatusbar.show();

    if ($(this).height() < minFooterHeight) { // if the height < #, hide it
        updateHeight(0, $footer);
        $footerAndStatusbar.hide();
    }

    updateHeight(); // update #mainWrap height
},
resize: function (event, ui) {
    $footerContent.height($(this).height() - 35);

    updateHeight(); // On footer resize, calculate and resize
}
}).css('height', Math.ceil((footerHeight + footerHeight / 2) / 2)); ;

$window.resize(function () { // Window resize
    updateHeight();
    editTooltip.tooltip('reposition');
});

我意识到$ window(又名$(window))调整大小是在每个像素被拖动的情况下被触发,(虽然我不确定为什么)导致巨大的性能削减。基本上,我的问题是,为什么调用窗口调整大小?什么是“放手”

1 个答案:

答案 0 :(得分:0)

尝试使用resizestop代替resize

resizestop: function (event, ui) {
    $footerContent.height($(this).height() - 35);

    updateHeight(); // On footer resize, calculate and resize
}

不同之处在于每次拖动鼠标时都会调用resize。根据{{​​1}}功能的复杂程度,这可能会变得非常慢。

updateHeight()仅在调整大小完成后调用 - 即。点击/拖动结束。

相关问题