What's the difference between “onwheel” and “onscroll” events?

前端 未结 4 2018
不知归路
不知归路 2020-12-20 13:09

When I tried to change the default scroll bar property, I found that it\'s not convenient by rewriting callback function for scroll() or onscroll e

4条回答
  •  隐瞒了意图╮
    2020-12-20 14:01

    onwheel specifically fires when the mouse wheel is spun. onscroll fires for any kind of scrolling, including keyboard buttons like the arrow keys, Home, End, Page Up, Page Down, space bar, tabbing etc.

    Note that onwheel is non-standard and should be avoided unless you're specifically targeting browsers that support it and/or are providing an extra feature whose absence won't be felt.

提交回复
热议问题