Parallax on scrollevent
How do I make an parallax on scrollevent?
Trying requestAnimationFrame om parallax. What is a parallax on scrollevent? How do you make a parallax on scrollevent? This script and codes were developed by Paul on 27 October 2022, Thursday.
Parallax on scrollevent - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>parallax on scrollevent</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="car"></div> <script src="js/index.js"></script>
</body>
</html>
Parallax on scrollevent - Script Codes CSS Codes
body { height: 6000px; width: 100%; background: darkgrey; margin: 0px;
}
.car { background: url(http://www.volkswagen-polo.com/docroot/assets/img/car_blue.png) no-repeat center; position: fixed; height: 280px; width: 140px; top: 10px; left: 300px;
}
Parallax on scrollevent - Script Codes JS Codes
var car;
document.addEventListener("DOMContentLoaded", function(){ window.addEventListener('scroll', function(){ // hier werden 2 args erwarte, bei florian ist nur eines? requestAnimationFrame(animate); }); window.addEventListener('load', function(){ car = document.querySelector('.car'); }); function animate(){ var percent = window.scrollY/window.scrollMaxY; var pos = transform(percent); car.style.webkitTransform = "translateY("+pos.y+"px)"; console.log(pos.x); } function transform(p){ if(p <.3){ p = p * 10/3; return{ y : 0 }; } else if(p < .9){ // hier ?? magic?? p = (p - .3) * 10/6; return{ y: -500 }; } else{ p = (p -.9) *10; return{ y: -1000 }; } }
});
![Parallax on scrollevent - Script Codes](http://shots.codepen.io/paulq/pen/KAJoH-512.jpg)
Developer | Paul |
Username | paulq |
Uploaded | October 27, 2022 |
Rating | 3 |
Size | 2,386 Kb |
Views | 12,144 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Three js | 2,353 Kb |
A Pen by paul | 2,390 Kb |
Parallax on scrollevent | 2,386 Kb |
Sticky header | 2,309 Kb |
Setter getter closure functions | 1,662 Kb |
Input tabcontainer | 4,390 Kb |
Flexbox-Slider-Test | 1,666 Kb |
TabContainer pure css3 | 2,769 Kb |
Sitemap getter | 1,823 Kb |
Keyframes and Webkits with LESS | 2,630 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Drawing a Terminal with CSS | Lachlanjc | 3,185 Kb |
Angular Route | Arun_v606 | 1,837 Kb |
Image Stack Test SCSS | CalvinMorett | 2,799 Kb |
Sidebar Thing | Jonambas | 2,779 Kb |
Airbnb Homepage | SindhujaD | 2,480 Kb |
Out of the blue | Giaco | 2,537 Kb |
Video Player Custom Controls | EleftheriaBatsou | 3,665 Kb |
Importable Clearfix | Corysimmons | 1,411 Kb |
Loading animation - freedom purchase | Rocbear | 2,567 Kb |
Cartoon Bomb | Tcmulder | 4,929 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!