搜索

首页  >  问答  >  正文

javascript - 怎么监听手机端屏幕的滑动以及滑动距离顶端的距离啊?

怎么监听手机端屏幕的滑动啊,同时计算出滚动距离顶部多少?

$('body').bind('touchmove', function(e) {
       var  winHeight = $(window).scrollTop();
        console.log(winHeight);
    });

我这样写的一直是0? 监听scroll没效果的!求大神

黄舟黄舟2833 天前700

全部回复(4)我来回复

  • 某草草

    某草草2017-05-19 10:13:07

    雷雷

    回复
    0
  • 習慣沉默

    習慣沉默2017-05-19 10:13:07

    $('body').on("touchstart",function(ev){
            var  winHeight = $(window).scrollTop();
            $('body').on("touchmove",function(ev){
                console.log(winHeight);
            })
        });

    你试试这样写看看呗

    回复
    0
  • 仅有的幸福

    仅有的幸福2017-05-19 10:13:07

    雷雷

    回复
    0
  • 大家讲道理

    大家讲道理2017-05-19 10:13:07

    雷雷

    回复
    0
  • 取消回复