Custom scroll bar behavior in Javascript?

爱⌒轻易说出口 提交于 2019-12-07 09:08:41

问题


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 possible to obtain the vertical scroll bar value in Javascript? Am I approaching this design wrong?


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/7630450/custom-scroll-bar-behavior-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!