Binding handlers to javascript scroll event — performance factor

▼魔方 西西 提交于 2019-12-11 12:35:00

问题


Im binding an event handler that does an if check to find the presence of an element in the viewport of screen and adjust width of 4-5 elements.

Im not really sure how scroll event works in javascript. But my gut feeling is that, scroll event is fired for even the 1px scroll we do -- in which case scroll sounds more like a continuous event once we start scrolling fast(correct me if Im wrong here). If thats the case, wouldnt calculating viewport and checking the presence of an element inside it and doing dom manipulation would be too much of hit on the performance?

Please help me understand how the scroll event works if my assumption is wrong here!

Thanks.

来源:https://stackoverflow.com/questions/17418532/binding-handlers-to-javascript-scroll-event-performance-factor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!