如果在chrome中放大/缩小窗口,则滚动事件代码不会执行 [英] Code on scroll event is not executing if window is zoomed in/out in chrome

查看:127
本文介绍了如果在chrome中放大/缩小窗口,则滚动事件代码不会执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下脚本在滚动到达页面底部时加载数据,并且在所有浏览器中都可以正常工作.但是,如果我使用键盘快捷键Ctr+Ctrl-(>或<默认缩放)手动放大/缩小窗口,则在chrome中似乎不起作用.

I'm using below script to load data on scroll reaches bottom of the page and its working fine in all browsers. But it doesn't seems working in chrome if i manually zoom in / zoom out window using keyboard shortcuts Ctr+ or Ctrl-(> or < default zoom ).

if (($(window).scrollTop() + $(window).innerHeight()) >= $(document).height()){ 
    loadData();
 }

推荐答案

这似乎是chrome中的错误,我已经报告了此

This seems to be a bug in chrome and i have reported this here>>

甚至,我通过应用较小的高度减小幅度(-100)使其满足滚动条末端之前的条件来使其工作.

Even, i made it working by applying a small height reduction (-100) to satisfy the condition little before it reaches the scroll end.

代码是这样的,

if (($(window).scrollTop() + $(window).innerHeight()) >= $(document).height()-100){ 
    loadData();
 }

编辑

Chrome开发人员在上面链接的错误中提出了以下建议.

Chrome developers gives following suggestion in the bug linked above.

$(window).scrollTop() + $(window).height() >= $(document).height()

  • 尚未从我这边进行测试.
  • 这篇关于如果在chrome中放大/缩小窗口,则滚动事件代码不会执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆