避免事件重复触发
1
2
3
4
5
// 每次事件触发后,先清除之前的事件,再继续执行
floor.$win.on('scroll resize', floor.showFloor = function() {
clearTimeout(floor.floorTimer);
floor.floorTimer = setTimeout(floor.timeToShow, 250);
})
参考
- https://class.imooc.com/lesson/807#mid=20292