Jquery resizable reposition handle after scroll

こ雲淡風輕ζ 提交于 2019-12-22 14:17:07

问题


I have an html table within a container. the container has a height, and its overflow y set to auto to create a scrollbar

.table-container {
   height: 175px;
    border-bottom: 2px solid #EEEEEE;
    overflow-y: auto;

}

I have also made the container resizable using JQuery UI resizable.

$(function () {

$(".table-container").resizable({ handles: "s" });
});

unfortunately when I use the scrollbar my resizable handles moves. I would like for it to stay at the bottom of the container. here is the fiddle.

https://jsfiddle.net/oyb3r6u8/1/enter link description here


回答1:


You could use jquery to maintain the position of the handle during the drag based on the position of the drag.

Here is the full update to your code: https://jsfiddle.net/k3e5ma2s/


$(function () {

    $(".table-container").resizable({ handles: "s", resize: updateHandle });

    $( ".table-container" ).scroll(function() {
        updateHandle();
    });

    updateHandle();

});

function updateHandle() {
    table = $('.table-container');
    var bottom =  table.scrollTop() + table.outerHeight(true) - $('.ui-resizable-handle').outerHeight() - 5;
    $('.ui-resizable-handle').css('top', bottom + 'px');
}


来源:https://stackoverflow.com/questions/36726482/jquery-resizable-reposition-handle-after-scroll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!