Snap scroll
How do I make an snap scroll?
What is a snap scroll? How do you make a snap scroll? This script and codes were developed by Mikita on 19 January 2023, Thursday.
Snap scroll - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Snap scroll</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<section class="full"> <span>section 1</span>
</section>
<section class="long is-1"> <span>section 2</span>
</section>
<section class="long is-2"> <span>section 3</span>
</section>
<section class="short"> <span>section 4</span>
</section> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/velocity/1.5.0/velocity.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Snap scroll - Script Codes CSS Codes
html,
body { height: 100%; font-family: sans-serif;
}
section { text-align: center; color: #fff; font-size: 0; line-height: 0; vertical-align: middle;
}
section span { font-size: 3rem; vertical-align: middle;
}
section:before { content: ''; display: inline-block; height: 100%; vertical-align: middle;
}
section:nth-child(1) { background: #c54;
}
section:nth-child(2) { background: #5c4;
}
section:nth-child(3) { background: #45c;
}
section:nth-child(4) { background: #c5c;
}
section.full { height: 100%;
}
section.long { height: 1200px;
}
section.short { height: 150px;
}
Snap scroll - Script Codes JS Codes
var body = $("body"), win = $(window), lastScrollTop = 0, pending = false, sections = $('section'), activeSlide = null;
win.on('scroll', scrollHandler);
function scrollHandler(e) { if (pending) return; var scrllTop = win.scrollTop(), winHeight = win.height(), sectionOffset; for (var i = 0, len = sections.length; i < len; i += 1) { sectionOffset = $(sections[i]).offset().top if ( scrllTop >= sectionOffset && scrllTop + winHeight > sectionOffset ) { activeSlide = sections[i]; } } if ( checkDirection(e) === 'down' && scrllTop + winHeight >= $(activeSlide).offset().top + $(activeSlide).outerHeight(true) ) { scrllTo( $(activeSlide).next().offset().top ); } else if ( checkDirection(e) === 'up' && scrllTop < $(activeSlide).next().offset().top && scrllTop + 100 > $(activeSlide).next().offset().top) { scrllTo( $(activeSlide).offset().top + $(activeSlide).outerHeight() - winHeight ); }
}
function checkDirection (e) { var top = win.scrollTop(), result = null; if (lastScrollTop > top) { result = 'up'; } else if (lastScrollTop < top) { result = 'down'; } setTimeout(function(){ lastScrollTop = top; }, 0); return result;
}
function scrllTo(offsetTop) { pending = true; $("html").velocity("scroll", { offset: offsetTop, duration: 500, easing: "linear", complete: function(elements) { pending = false; } });
}
![Snap scroll - Script Codes](http://shots.codepen.io/MikitaLisavets/pen/jPpayj-512.jpg)
Developer | Mikita |
Username | MikitaLisavets |
Uploaded | January 19, 2023 |
Rating | 3 |
Size | 2,732 Kb |
Views | 6,072 |
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 |
Loader | 3,321 Kb |
Note scales | 12,435 Kb |
Particle system | 5,454 Kb |
Accordion card | 2,839 Kb |
Simple pure CSS3 donut chart | 2,607 Kb |
Angular chart directive | 3,298 Kb |
Math Trick | 3,970 Kb |
Spin menu | 5,186 Kb |
Cards Menu | 4,611 Kb |
Rollers | 4,089 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 |
CSS3 Form | Tusharbandal | 1,836 Kb |
Sidebar Thing | Jonambas | 2,779 Kb |
Blog Concept 2 | JGallardo | 2,994 Kb |
Modal Dialog | Gigaleet | 2,251 Kb |
Siema - add pagination to prototype | Pawelgrzybek | 2,575 Kb |
Ipad Mini Showcase | Hornebom | 10,479 Kb |
A Pen by Jason Kinney | Jason-kinney | 1,980 Kb |
Portfolio Page | KaylaMT | 1,983 Kb |
Fellowship of the Ring | Aussieyang | 2,639 Kb |
DIV wormhole | Heydon | 1,932 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!