滚动重绘前的JavaScript事件? [英] javascript event before scroll redraw?

查看:113
本文介绍了滚动重绘前的JavaScript事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



问题是大多数浏览器在scoll之后绘制div,但是在之前 onscoll事件触发,所以最终得到1或2帧,其中div具有旧样式,但视口处于新的滚动位置。



$ b

如何防止这种情况?

解决方案

p>也许将body设置为overflow:hidden启动,并将其更改为overflow:在第一个onscroll触发时自动运行。


I have a javascript function on the onscoll event to change a div's style.

The problem is that most browsers draw the div after a scoll but before the onscoll event fires, so you end up with 1 or 2 frames where the div has the old style but the viewport is at the new scroll position. This can cause ugly flickering.

How do you prevent this?

解决方案

Maybe set the body to overflow:hidden to start, and change it to overflow:auto once the first onscroll fires.

这篇关于滚动重绘前的JavaScript事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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