【问题标题】:Why does the scroll event in JavaScript differ from device to device?为什么 JavaScript 中的滚动事件因设备而异?
【发布时间】:2019-08-30 05:10:46
【问题描述】:

我是目前正在通过Spring-MVC 从事该项目的开发人员。我当前的问题不是根据设备滚动事件。我当前的滚动事件代码如下:

$(function(){

    $(window).scroll(function(){
        if ($(window).scrollTop() == ($(document).height() - $(window).height())) {
            push_list(address); // not come in 
            logcheck() // not come in
        }  
    });

});

目前,此滚动事件条件函数在web 上运行良好。它在 LG Nexus 5 //Android 6 上运行良好。但是,它不适用于 LGV30//Android8SAMSUNG NOTE8 Android8...可能等等。这是Android 版本的问题吗?有针对这个的解决方法吗?

现在这是webview screen 的一个函数。

【问题讨论】:

    标签: javascript android html spring event-handling


    【解决方案1】:

    通过更改高度值解决。通过比较content 的高度与top 的值加上height 的值,而不是它是否等于TOP 的值来解决此问题。

        $(window).scroll(function(){
            var scrollT = $(this).scrollTop();
            var scrollH = $(this).height();                 
            var contentH = $('#pushlist').height(); 
            if ( scrollT + scrollH + 1 >= contentH ) push_list(address);
        });
    

    【讨论】:

      猜你喜欢
      • 2018-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-24
      • 1970-01-01
      • 2016-09-14
      相关资源
      最近更新 更多