开发者

Custom scroll bar behavior in Javascript?

开发者 https://www.devze.com 2023-04-09 21:15 出处:网络
I\'d like to reproduce an effect similar to this page: http://artofflightmovie.com/ where the vertical scrollbar controls the progression of the browser \"viewport\" over a pre-defined path.

I'd like to reproduce an effect similar to this page: http://artofflightmovie.com/ where the vertical scrollbar controls the progression of the browser "viewport" over a pre-defined path.

I am thinking the easiest way of going about this is through the use of javascript to read the scroll bar value and position background elements accordingly.

Is it poss开发者_高级运维ible to obtain the vertical scroll bar value in Javascript? Am I approaching this design wrong?


Is it possible to obtain the vertical scroll bar value in Javascript?

var scrollTop = document.documentElement.scrollTop || window.pageYOffset;

Am I approaching this design wrong?

It seems like a valid approach.


I would think that you'd want to:

  1. Create an element with the desired scrollbar
  2. Hook up an event handler for scroll events
  3. Write logic in that event handler for how you guide your main page depending upon the scroll position you get in the event handler
0

精彩评论

暂无评论...
验证码 换一张
取 消