Animated scroll-dependant menu using scrollMonitor
How do I make an animated scroll-dependant menu using scrollmonitor?
In this example I use scrollMonitor to fix a menu to the top of the page once it normally would leave the viewport. As an extra I also use CSS3 transition to animate the menu into a new appearance.. What is a animated scroll-dependant menu using scrollmonitor? How do you make a animated scroll-dependant menu using scrollmonitor? This script and codes were developed by Creative Punch on 09 December 2022, Friday.
Animated scroll-dependant menu using scrollMonitor - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Animated scroll-dependant menu using scrollMonitor</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> <h1>Scroll down</h1>
<h2>And watch the menu bar</h2>
<nav id="menu"> <h1 id="sitename">MySite</h1> <ul> <li class="active"><a href="#">Home</a></li> <li><a href="#">Blog</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul>
</nav> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://rawgithub.com/sakabako/scrollMonitor/master/scrollMonitor.js'></script> <script src="js/index.js"></script>
</body>
</html>
Animated scroll-dependant menu using scrollMonitor - Script Codes CSS Codes
@import url(https://fonts.googleapis.com/css?family=Roboto);
body { height: 2000px; font-family: Roboto, sans-serif; -webkit-font-smoothing: antialiased;
}
h1, h2 { text-align: center;
}
h1 { color: #222;
}
h2 { color: #555;
}
nav#menu { margin-top: 50px; background: #3498db; text-align: center; height: 50px; width: 100%;
}
nav#menu ul { padding: 0; background: white; margin: 0 auto; display: inline-block; height: 50px;
}
nav#menu ul li { float: left; padding: 0 20px; background: #3498db; list-style: none; margin-right: 5px; line-height: 50px; height: 50px; /* * This element will get an alternative style * once we apply the "scrolled" class. * We also want a nice animation so we can * simply set CSS3 transitions for this. */ transition: margin 0.1s ease-in-out;
}
nav#menu ul li:nth-child(1) { margin-left: 5px;
}
nav#menu ul li.active { background: #2980b9;
}
nav#menu ul li a { color: white; text-decoration: none; font-size: 1.3em;
}
nav#menu h1#sitename { font-size: 1.2em; line-height: 50px; margin: 0; position: absolute; left: 0.5em; color: white; opacity: 0; /* * Same thing here as with the menu items. * This element will be animated into its * alt. state with the transition property */ transition: opacity 0.1s ease-in-out;
}
/********************************************* * Once the 'scrolled' class is toggled * we can set any alternative styling that we * want for the menu bar *********************************************/
nav#menu.scrolled { margin: 0; position: fixed; top: 0;
}
nav#menu.scrolled ul li { margin: 0;
}
nav#menu.scrolled h1#sitename { opacity: 1;
}
Animated scroll-dependant menu using scrollMonitor - Script Codes JS Codes
var menu = $('nav#menu');
var watcher = scrollMonitor.create( menu );
watcher.lock();
watcher.stateChange(function() { $(menu).toggleClass('scrolled', this.isAboveViewport)
});
Developer | Creative Punch |
Username | CreativePunch |
Uploaded | December 09, 2022 |
Rating | 4.5 |
Size | 2,734 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 |
Long shadow social icons with Sass | 4,129 Kb |
Textured text | 1,947 Kb |
Glowing lights loader animation with pure CSS | 2,785 Kb |
Animated bar chart | 3,124 Kb |
SVG blurred header | 3,102 Kb |
Animated CSS3 social buttons | 2,573 Kb |
Retro text with hover | 1,578 Kb |
JQuery Adaptive Slider Demo | 3,568 Kb |
Sass colorful shadows experiment | 2,886 Kb |
3D jQuery rotator | 3,238 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 |
Tree growth tests | Orchard | 3,818 Kb |
Rrremark.com Overlay Highlighter | Derickruiz | 4,438 Kb |
A Pen by Ash | Littleginger | 2,386 Kb |
A Pen by Moeid Saleem | Moeidsaleem | 1,862 Kb |
Css3 only dropdown menu | Riogrande | 2,519 Kb |
HTM5 picture dropzone | Jaysalvat | 2,576 Kb |
A Pen by Taylor Vowell | Taylorvowell | 5,962 Kb |
Vanilla JS - A toggleClass function | Woodwork | 2,532 Kb |
Sexy Social Buttons | Ipiyale | 2,226 Kb |
React Vote Component | Souporserious | 5,465 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!