[英]How can i make my page slide on scroll Jquery or CSS (or any other way)
I am wondering that how I can make my page slide when user scrolls the page.我想知道当用户滚动页面时如何使页面滑动。 I have searched for solutions all over the web but I have found nothing.我在整个 web 中搜索了解决方案,但我什么也没找到。 One solution had so much code it wasn't even worth it.一个解决方案有这么多代码,甚至不值得。
Is there an efficient way or using a CDN that will allow me to do this?有没有一种有效的方法或使用 CDN 可以让我这样做?
Note: its a smooth scrolling effect that keeps sliding subtly after you scroll up or down instead of abrupt scrolling as is the default.注意:它是一种平滑的滚动效果,在您向上或向下滚动后会保持微妙的滑动,而不是默认的突然滚动。
var html = $('html');
$('html').scroll(function() {
html.animate({},500, 'swing');
});
But of course that doesn't make much sense.但这当然没有多大意义。
I'm wondering if i should detect the direction of the scroll and based on that i add top:50px inside the CSS in the animate part or top:-50px if scroll direction is up.我想知道我是否应该检测滚动的方向,并基于此在动画部分的 CSS 内添加 top:50px,如果滚动方向向上,则添加 top:-50px。
What do you think?你怎么看? I'm not sure that would work.我不确定那会奏效。
I think you are talking about you need a custom jQuery plugin for scrolling.我想你在说你需要一个自定义的 jQuery 插件来滚动。 You can try http://manos.malihu.gr/jquery-custom-content-scroller/ And there are two code examples:您可以尝试http://manos.malihu.gr/jquery-custom-content-scroller/并且有两个代码示例:
You have also option to download the project from first URL.您还可以选择从第一个 URL 下载项目。
This is the simple example plugin and very helpful.这是一个简单的示例插件,非常有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.