使用JQuery设置滚动事件的边距 - 不稳定/跳跃/抖动运动

时间:2015-09-25 12:48:59

标签: jquery scroll margin internet-explorer-11 fixed

我有表格,我在X轴和Y轴上滚动(with JQuery)。但是当桌子滚动时,它们就像摇晃一样。

... 所以我的问题是:为什么会发生这种震动,我该如何防止这种震动?

var leftOffset = parseInt($(".tablecontainer").css('margin-left')); 
    hhOffset = parseInt($(".headsholder").css('margin-left'));
    fixOffset = parseInt($(".fixedphead").css('margin-left'));
    eisastanaYOffset = parseInt($(".eisastana").css('margin-left'));

    $(".contentbox").scroll(function(){
        $(".tablecontainer").css({
            'margin-left': $(this).scrollLeft() + leftOffset 
        });
        $(".tableheads").css({
            'margin-left': -$(this).scrollLeft()  
        });
        $(".headsholder").css({
            'margin-left': hhOffset - $(this).scrollTop()
        });
        $(".fixedphead").css({
            'margin-left': fixOffset -$(this).scrollTop()
        });
        $(".eisastana").css({
            'margin-left': eisastanaYOffset -$(this).scrollTop()
        });
    });

1 个答案:

答案 0 :(得分:0)

我使用 .stop() - Jquery.stop().animate(); - 并且停止了摇晃。