简体   繁体   English

滚动动作太远了

[英]Scroll is moving too far

Check this fiddle . 检查这个小提琴

Suppose the first visible element inside the scroll container is #1 element. 假设滚动容器内的第一个可见元素是#1元素。 In the above fiddle, I can see #1 , #2 , #3 and #4 elements. 在上面的小提琴中,我可以看到#1#2#3#4元素。 and if I am right, if I scroll once I should be able to see next 4 elements ie #5 , #6 , #7 and #8 . 如果我是对的,如果我滚动一次,我应该能够看到接下来的4个元素,即#5#6#7#8 But when I scroll once through mousewheel, the scroll container is moving to #15 element. 但是当我通过鼠标滚轮滚动一次时,滚动容器将移动到#15元素。

Please help. 请帮忙。

// update content every second
function addChild() {
    var el = $('<div></div>').html('#' + $('#testDiv').children().length)
        .css({
        padding: '3px',
        border: '1px solid #ccc',
        margin: '5px'
    });
    $('#testDiv').append(el);

    // update slimscroll every time content changes
    $('#testDiv').slimscroll();
}

$('#testDiv').slimscroll({
    alwaysVisible: true,
    height: 150
});

for (var i = 0; i < 300; i++) {
    addChild();
}

PS: I filled an issue on github PS:我在github上填写了一个问题

Check this: 检查一下:

// update content every second
function addChild() {
    var el = $('<div></div>').html('#' + $('#testDiv').children().length)
        .css({
        padding: '3px',
        border: '1px solid #ccc',
        margin: '5px'
    });
    $('#testDiv').append(el);

    // update slimscroll every time content changes
    $('#testDiv').slimscroll();
}


for (var i = 0; i < 300; i++) {
    addChild();
}

$('#testDiv').slimscroll({
    alwaysVisible: true,
    height: 150
});

JSFiddle 的jsfiddle

I have just loaded the div before the slimscroll 我刚刚在slimscroll之前加载了div

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM