stutrek / scrollmonitor

A simple and fast API to monitor elements as you scroll

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

horizontal scrolling

musicformellons opened this issue · comments

Looks nice! Can you use it also for horizontal instead of vertical scrolling?

Unfortunately you cannot. It's a surprisingly rare feature request.

Actually it will be very usefull

I have to agree horizontal scroll would be useful.

+1 it would be super useful to carousel

Yes please!

I don't recommend but if you really want to have or need a quick-win solution (but dirty), clone the not minimized version of scrollMonitor.js (and call it scrollMonitorHoriz.js, e.g.) and apply the following changes to the code:

  1. rename all "scrollMonitor" to "scrollMonitorHoriz"
  2. apply the following replacements (case sensitive):
  • "top" => "left"
  • "Top" => "Left"
  • "bottom" => "right"
  • "Bottom" => "Right"
  • "height" => "width"
  • "Height" => "Width"
  • "window.pageYOffset" => "window.pageXOffset"

and this should make the trick but that new version will no longer support the vertical scrolling...

🤘 Nice hack.

I think there's a second place you'll need to edit if you want it to work in scroll containers too, but if it works keep doing it.

+1 It would be very helpful!