Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript节流 | Davis #20

Open
lvzero535 opened this issue Jul 20, 2019 · 0 comments
Open

JavaScript节流 | Davis #20

lvzero535 opened this issue Jul 20, 2019 · 0 comments

Comments

@lvzero535
Copy link
Owner

https://lvdongfeng.vip/2019/07/20/JavaScript%E8%8A%82%E6%B5%81/#more

JavaScript节流节流就是持续触发的事件,每隔一段时间,只执行一次。如鼠标移动触发的事件,如果太频繁,导致性能问题,就需要用到节流。 根据首次是否执行以及尾次是否执行,实现也是不同。使用leading和trailing分别判断首尾是否执行。 节流的实现有两种方式,一:时间戳,二:是定时器。 使用时间戳当事件触发时,取出当前的时间戳,然后减去之前的时间戳(一开始设置为0),如果大于设置的间隔时

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant