Horizontal data update is not working on scroll

前端 未结 3 2273
被撕碎了的回忆
被撕碎了的回忆 2021-02-20 03:19

I have a big array and I need to render it into a table. Instead of rendering all items I am rendering only few items horizontally and vertically. Then on scroll based on mouse

3条回答
  •  攒了一身酷
    2021-02-20 03:58

    I've noticed that your jsbin example has been modified slightly and is using the wheelDelta attribute. This is why you are not able to distinguish between updating horizontally and vertically. You need to use wheelDeltaX and wheelDeltaY, which will wither be a value or zero, depending on whether the user scrolled vertically or horizontally.

    Also, be careful using the mousewheel event, it is not standards compliant so may come back to haunt you. Might be worth having a look at the JQuery source to see how the scroll() method implements these handlers. I would imagine there is a timer that monitors the scroll offsets of the element, which triggers synthetic events when the object scrolls. But that is a complete wild guess. Like I said, you are better off having a look at it.

提交回复
热议问题