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 }; } }
});
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 |
Flexbox-Slider-Test | 1,666 Kb |
TabContainer pure css3 | 2,870 Kb |
TabContainer pure css3 | 2,769 Kb |
Setter getter closure functions | 1,662 Kb |
Dropdow | 2,466 Kb |
A Pen by paul | 1,441 Kb |
Canvas tutorial | 2,043 Kb |
Sitemap getter | 1,823 Kb |
Callback function | 2,939 Kb |
Input tabcontainer | 4,390 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 |
A form arranged using automatic placement. | Vikasford | 2,103 Kb |
Voting App - register | MatheusLima92 | 1,948 Kb |
Drag n Drop | Martin42 | 2,594 Kb |
Image Hover | Johnheiner | 3,409 Kb |
Ripples in water | Nobitagit | 2,704 Kb |
Preloader | Rikki_Sixx | 2,815 Kb |
Confirm Close Of Foundation Reveal Modal | Winghouchan | 1,818 Kb |
Custom Select Element | Agrayson | 3,616 Kb |
Twinkling Stars | Ripley6811 | 2,750 Kb |
RRC wrapSwitch | Pshrmn | 2,922 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!