Detecting mousewheel on the x-axis (left and right) with Javascript

后端 未结 5 1942
面向向阳花
面向向阳花 2020-12-13 10:43

I know it\'s possible to detect up and down e.g.

    function handle(delta) {
    if (delta < 0) {
        alert(\'down\');
} else {
    alert(\'up\');
           


        
5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-13 11:06

    I believe you can find the 'horizontal' or x-axis data from

    event.originalEvent.wheelDeltaX
    

    You should debug the code, and see what properties the event object has at runtime. This should confirm or deny if that property exists. From there, it is just a matter of detecting if the value differs.

提交回复
热议问题