简体   繁体   中英

On a webpage can I hijack the vertical scrolling action and make it horizontal?

On a webpage can I hijack the vertical scrolling action and make it horizontal?

Please try and ignore the potential usability issues.

On a webpage can I hijack the vertical scrolling action and make it horizontal?

Not as far as I know (except maybe by rotating the element - but that is probably not what you want).

You would have to re-arrange the contents to make the vertical scroll bar go away, and force a horizontal one instead.

Whether that is possible will strongly depend on the nature of the HTML elements inside the page.

Yes you can do this.

Vertical scrolling is set to element.scrollTop

You could simply add a loop that catches scrollTop when it changes, sets it back to zero and then sets the scrollLeft to be = to the changed position.

More so, an even better solution is to overwrite the onscroll event.

window.onscroll = function(event){

 event.preventDefault() // Stops the page from scrolling vertically.


 window.scrollLeft = event.scrollTop // This is not the correct event attribute, youll have to locate it yourself.
}

这是一个执行此操作的jQuery插件,您可以将其指定为仅在鼠标悬停在目标元素上时才起作用: http : //flowplayer.org/tools/scrollable/index.html

You could hook into the scroll event, check which plane is being scrolled, if it was the vertical then set the difference as the horizontal scroll and set the vertical scroll to it's previous value. Though I can imagine that would be incredibly expensive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM