ScrollIntoView() causing the whole page to move

后端 未结 12 2071
庸人自扰
庸人自扰 2020-11-30 21:40

I am using ScrollIntoView() to scroll the highlighted item in a list into view. When I scroll downwards ScrollIntoView(false) works perfectly. But when I scroll upwards, Scr

12条回答
  •  孤城傲影
    2020-11-30 22:04

    I've added a way to display the imporper behavior of the ScrollIntoView - http://jsfiddle.net/LEqjm/258/ [it should be a comment but I don't have enough reputation]

    $("ul").click(function() {
        var target = document.getElementById("target");
    if ($('#scrollTop').attr('checked')) {
        target.parentNode.scrollTop = target.offsetTop;    
    } else {
            target.scrollIntoView(!0);
    }
    });
    

提交回复
热议问题