简体   繁体   English

向上和向下滚动Javascript上的动画

[英]Animation On Scroll Up and Down Javascript

Hey I am trying to replicate the on scroll animations on https://pixelgrade.com/demos/pile . 嘿,我试图复制https://pixelgrade.com/demos/pile上的滚动动画。 I have tried ScrollMagic and Wow.js , but I am having great difficulty. 我尝试过ScrollMagic和Wow.js,但我遇到了很大困难。 I have found the vanilla code for detecting the direction in which the user is scrolling but that has some problems. 我找到了用于检测用户滚动方向但有一些问题的vanilla代码。 If I set an on scroll listener, It would be animating every single thing on the page when the user scrolls. 如果我设置了一个滚动监听器,当用户滚动时,它将为页面上的每一件事设置动画。 Any help would be appreciated , thank you. 任何帮助将不胜感激,谢谢。

Edit: I am referring to the image animations under the header. 编辑:我指的是标题下的图像动画。 (The ones in a grid.) (网格中的那些。)

I'm one of the Pile theme developers(the PHP one, unfortunately for you) and I can tell you that my colleague, Razvan Onofrei, created a jQuery plugin called Rellax inspired by the development of Pile2 . 我是Pile主题开发人员之一(不幸的是你的PHP),我可以告诉你,我的同事Razvan Onofrei创建了一个名为Rellax的jQuery插件,受到Pile2开发的启发

With this library, you should be able to replicate Pile's behavior. 使用此库,您应该能够复制Pile的行为。

Block .item scroll 3x speed from scrollbar. 阻止.item从滚动条滚动3倍速度。 Show in a full screen. 全屏显示。

 window.onscroll = function() { var posTop = (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop; document.getElementById('item').style.top = 1000 - parseInt(posTop * 3) + 'px'; } 
 body { height: 200vh; position: relative; } #item { width: 200px; height: 200px; position: absolute; top: 1000px; background-color: red; } 
 <div id="item"></div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM