Answer the question
In order to leave comments, you need to log in
Is there a simple way to remap the mouse wheel to vertical scroll?
So it goes.
I thought for a long time, googled for a long time.
Decided to ask just in case.
If not, what is the best way to implement it?
PS: without jQuery and other bells and whistles - native JS according to ES6
Answer the question
In order to leave comments, you need to log in
document.onwheel = function(e){
e.preventDefault();
//Дельту желательно немного приумножать
window.scrollBy(e.deltaY, 0); //С вертикального на горизонтальный
window.scrollBy(0, e.deltaX); //С горизонтального на вертикальный
}
In my case, the scroll occurs not in the window, but in the c block. id="timeline"
For this case, the code is as follows:
window.timeline.onwheel = e => {
e.preventDefault();
timeline.scrollLeft = timeline.scrollLeft + e.deltaY;
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question