CSS Animation seeking with JavaScript

Developer
Size
3,053 Kb
Views
20,240

How do I make an css animation seeking with javascript?

What is a css animation seeking with javascript? How do you make a css animation seeking with javascript? This script and codes were developed by Peter Hrynkow on 14 September 2022, Wednesday.

CSS Animation seeking with JavaScript Previews

CSS Animation seeking with JavaScript - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>CSS Animation seeking with JavaScript</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="thing" style=""></div>
<div class="info"><h4>Scroll Down</h4><p>Here’s how you can seek to a specific frame in a CSS Animation using JavaScript. The trick is to use a negative animation delay.</p></div>
<div class="thing" style=""></div>
<div class="info"><h4>Extra text</h4><p>Here is some more text ipsum dolor site amet. Mauris iaculis porttitor posuere. Praesent id metus massa, ut blandit odio. Proin quis tortor orci. Etiam at risus et.
</p></div> <script src="js/index.js"></script>
</body>
</html>

CSS Animation seeking with JavaScript - Script Codes CSS Codes

body { padding-bottom: 500px;
}
.thing { margin: 100px auto; border: 1px solid #ccc; width: 100px; height: 100px; -webkit-animation: move 1s linear infinite; animation: move 1s linear infinite; -webkit-animation-direction: alternate; animation-direction: alternate; -webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-play-state: paused; animation-play-state: paused; will-change: transform;
}
.info { margin: 0 auto; max-width: 500px; padding: 0 20px; margin: 100px auto;
}
@-webkit-keyframes move { 0% { -webkit-transform: translateY(0px); transform: translateY(0px); } 100% { -webkit-transform: translateY(200px) rotate(45deg); transform: translateY(200px) rotate(45deg); }
}
@keyframes move { 0% { -webkit-transform: translateY(0px); transform: translateY(0px); } 100% { -webkit-transform: translateY(200px) rotate(45deg); transform: translateY(200px) rotate(45deg); }
}

CSS Animation seeking with JavaScript - Script Codes JS Codes

'use strict';
{ (function () { var things = Array.from(document.querySelectorAll('.thing')); var scrollPosition = 0; var render = function render() { var complete = Math.min(scrollPosition / 500, 1) * -1; things.forEach(function (thing) { thing.style.animationDelay = complete + 's'; }); window.requestAnimationFrame(render); }; var scrollHandler = function scrollHandler() { scrollPosition = window.pageYOffset; }; window.addEventListener('scroll', scrollHandler); render(); })();
}
CSS Animation seeking with JavaScript - Script Codes
CSS Animation seeking with JavaScript - Script Codes
Home Page Home
Developer Peter Hrynkow
Username peterhry
Uploaded September 14, 2022
Rating 3
Size 3,053 Kb
Views 20,240
Do you need developer help for CSS Animation seeking with JavaScript?

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!

Peter Hrynkow (peterhry) Script Codes
Create amazing blog posts with AI!

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!