在Javascript中自定义滚动条行为? [英] Custom scroll bar behavior in Javascript?

查看:96
本文介绍了在Javascript中自定义滚动条行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想重现与此页面类似的效果: http://artofflightmovie.com/ 垂直滚动条通过预定义路径控制浏览器视口的进度。

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.

我正在考虑解决这个问题的最简单方法是通过使用javascript来读取滚动条的值并相应地定位背景元素。

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.

是否可以在Javascript中获得垂直滚动条值?我接近这个设计错了吗?

Is it possible to obtain the vertical scroll bar value in Javascript? Am I approaching this design wrong?

推荐答案


是否有可能获得垂直滚动条值Javascript?

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.

这篇关于在Javascript中自定义滚动条行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆