Catching panels on scroll
How do I make an catching panels on scroll?
JS Controlled panel catching on scroll.For more info on requestAnimationFrame: https://css-tricks.com/using-requestanimationframe/. What is a catching panels on scroll? How do you make a catching panels on scroll? This script and codes were developed by Nicolas Udy on 12 January 2023, Thursday.
Catching panels on scroll - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Catching panels on scroll</title> <link rel='stylesheet prefetch' href='css/wxxzbj.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <main class="catch prompt"> <header class="header"> <h1 class="text">NICE<br>catch</h1> </header> <section class="catch__section info"> <aside class="catch__box"> <p class="text">Repellat voluptatibus, id cumque deleniti autem expedita sit, nemo suscipit quibusdam magni, odit sed et iste repudiandae?</p> <p class="text">Nemo quae pariatur earum nisi vel officiis praesentium delectus dicta sunt vero mollitia illo, eveniet, reiciendis blanditiis molestias at explicabo. Velit ea saepe quam non itaque reprehenderit consequatur ipsam fugiat?</p> <p class="text">Optio dolore, consequuntur temporibus possimus ipsam eveniet, fugit voluptates eos, iusto neque hic cupiditate.</p> </aside> <aside class="catch__box catch__box--dynamic js-catch"> <h2 class="text">insert some sort of<br>big bold statement here</h2> </aside> </section> <section class="catch__section catch__section--static static"> <aside class="catch__box"> <h2 class="text">i think<br>it's time</h2> </aside> <aside class="catch__box"> <h2 class="text">we take<br>a break</h2> </aside> </section> <section class="catch__section catch__section--right long"> <aside class="catch__box catch__box--small"> <p class="text">Praesentium facere quidem blanditiis, corporis in enim aliquam iure molestias pariatur rem expedita est dolorem error quia veniam cum sequi reiciendis impedit dicta, alias et temporibus repellendus.</p> </aside> <aside class="catch__box"> <h2 class="text">insert some inspiring quote from somebody who probably isn't actually the person who said it in the first place</h2> </aside> <aside class="catch__box catch__box--dynamic js-catch"> <p class="text">Odit nesciunt blanditiis, itaque deleniti magni corporis minus, in placeat veritatis cum vero reprehenderit.</p> <h2 class="text">Nemo!</h2> </aside> </section> <section class="footer"> <h3 class="text">kbye</h3> <h3 class="text">theEnd</h3> </section>
</main> <script src="js/index.js"></script>
</body>
</html>
Catching panels on scroll - Script Codes CSS Codes
.catch { padding-bottom: 101vh;
}
.catch__section { position: relative; padding-left: 50vw; background-color: #edf1f1;
}
.catch__section--right { padding-left: 0; padding-right: 50vw;
}
.catch__section--right .catch__box--dynamic { left: 50vw;
}
.catch__section--static { display: -webkit-box; display: -ms-flexbox; display: flex; padding: 0;
}
.catch__section--static .catch__box { min-height: 0; height: 100vh;
}
.catch__box { width: 50vw; min-height: 200vh; padding: 5vw; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; -webkit-box-align: stretch; -ms-flex-align: stretch; align-items: stretch;
}
.catch__box--small { min-height: 0;
}
.catch__box--dynamic { min-height: 0; height: 100vh; padding: 0 5vw; position: absolute; bottom: 100%; left: 0; -webkit-transform: translateY(100%); transform: translateY(100%);
}
.catch__box--dynamic.catch { position: fixed;
}
.catch__box--dynamic.release { position: absolute; bottom: 0; -webkit-transform: translateY(0); transform: translateY(0);
}
.text { font-weight: 900; text-align: center;
}
.header,
.footer { font-size: 4rem; line-height: .875;
}
.header { height: 96vh; color: #edf1f1; background-color: #2b303b; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center;
}
.info .catch__box:first-child { color: #2b303b; background-color: #39b08d; font-size: 2rem; line-height: 1.25;
}
.info .catch__box:last-child { color: #2b303b; font-size: 3rem; text-transform: uppercase; line-height: .875;
}
.static { font-size: 3rem; line-height: .875;
}
.static .catch__box:first-child { color: #edf1f1; background-color: #2b303b; text-transform: uppercase;
}
.static .catch__box:last-child { color: #2b303b;
}
.long .catch__box:first-child { color: #39b08d; background: #fff; font-size: 2rem; line-height: 1.25;
}
.long .catch__box:nth-child(2) { position: relative; color: #000; font-size: 3.25rem; line-height: .875; text-transform: uppercase;
}
.long .catch__box:nth-child(2)::after { content: ''; width: 100%; height: 100%; position: absolute; top: 0; left: 0; background: -webkit-linear-gradient(bottom, #4e5863, #edf1f1); background: linear-gradient(to top, #4e5863, #edf1f1); mix-blend-mode: screen;
}
.long .catch__box:last-child { color: #4e5863; background-color: #edf1f1; font-size: 2rem;
}
.long .catch__box:last-child .text:last-child { margin-top: .75rem; color: #39b08d; font-size: 2.75rem; text-transform: uppercase;
}
.footer { width: 100%; height: 102vh; position: fixed; bottom: -2vh; left: 0; z-index: -1;
}
.footer .text { line-height: 51vh; color: #edf1f1;
}
.footer .text:first-child { background-color: #2b303b;
}
.footer .text:last-child { background-color: #cf4646;
}
p + p { margin-top: 1em;
}
Catching panels on scroll - Script Codes JS Codes
(function scrollCatch() { var catchNodes = document.querySelectorAll('.js-catch'); if (catchNodes.length) { /*# setup #*/ // initialize debounce var buffer; var parentNodes = []; // store the parent nodes for faster access [].forEach.call(catchNodes, function(node) { parentNodes.push(node.parentNode); }); /*# update styles #*/ var updateNodes = function() { // store static values outside loop var vh = window.innerHeight; [].forEach.call(parentNodes, function(node, i) { // store repeat access values var catchNode = catchNodes[i]; var classList = catchNode.classList; var offset = node.getBoundingClientRect(); // set conditions var top = offset.top < 0; var bottom = offset.bottom < vh; var caught = classList.contains('catch'); // parent's top is above viewport top if (top && !bottom && !caught) { classList.add('catch'); if (classList.contains('release')) classList.remove('release'); // parent's bottom is above viewport bottom } else if (top && bottom && caught) { classList.add('release'); classList.remove('catch'); // parent's top is below viewport top } else if (!top && caught) { classList.remove('catch'); } }); // reset debounce buffer = false; }; // debounce updates var requestUpdate = function() { // only trigger if no update is in progress if (!buffer) requestAnimationFrame(updateNodes); buffer = true; }; document.addEventListener('scroll', requestUpdate); }
})();
Developer | Nicolas Udy |
Username | udyux |
Uploaded | January 12, 2023 |
Rating | 3 |
Size | 5,530 Kb |
Views | 10,120 |
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 |
CSSkateboard loading screen | 4,482 Kb |
Flipping ring buttons | 4,335 Kb |
Pure CSS Gallery hover effect | 4,802 Kb |
CSS only Select | 4,871 Kb |
ES6 Game of Snek | 7,851 Kb |
Cursor based dynamic perspective logo | 4,228 Kb |
Gradient Grid Lines | 3,884 Kb |
Snipcart CSS Animations | 18,476 Kb |
Pure CSS mountains | 4,178 Kb |
Automatic SVG Pie-Charts | 4,466 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 |
Review test | Otro_user_gil | 4,054 Kb |
Learning FlexBox | Alex_rodrigues | 2,821 Kb |
Loading animation | Codeams | 2,408 Kb |
JQuery AJAX reddit Exercise | Btholt | 1,777 Kb |
Polygon Dodecahedron in CSS | Vennsoh | 7,606 Kb |
PNotify Demo | Adittmar | 1,731 Kb |
Custom Select Element | Agrayson | 3,616 Kb |
Word Wrap Algorithm for Multiline Canvas Text | Peterhry | 2,349 Kb |
VerbalExpressions Converter | Cmalven | 2,607 Kb |
The Fantastic Mr Fox | MalZiiirA | 10,435 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!