相关疑难解决方法(0)

使用jQuery检测水平滚动div的结束

所以,我在div中得到了一些数据.它按日期分成几块.它使用jQuery和mousewheel插件水平滚动.

当div达到它的终点(最左边,最右边)时,我需要发射一个事件.我认为通过检测鼠标滚动插件中获取的数据,可以通过当前实现的方式来计算何时无法进一步滚动.我只需要朝着正确的方向轻推.这是为我进行水平滚动的代码:

$(document).ready(function () {        
    $('#timeline').mousedown(function (event) {
        $(this)
            .data('down', true)
            .data('x', event.clientX)
            .data('scrollLeft', this.scrollLeft);
        return false;
    }).mouseup(function (event) {
        $(this).data('down', false);
    }).mousemove(function (event) {
        if ($(this).data('down') == true) {
            this.scrollLeft = $(this).data('scrollLeft') + $(this).data('x') - event.clientX;
        }
    }).mousewheel(function (event, delta) {
        this.scrollLeft -= (delta * 30);
    }).css({
        'overflow' : 'hidden',
        'cursor' : '-moz-grab'
    });
});
Run Code Online (Sandbox Code Playgroud)

有人可以给我指点吗?谢谢!

jquery scroll mousewheel

4
推荐指数
2
解决办法
2万
查看次数

标签 统计

jquery ×1

mousewheel ×1

scroll ×1