-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from kimyvgy/fix/active-status
fix: the menu item's active status
- Loading branch information
Showing
6 changed files
with
212 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> | ||
<title>Simple Scrollspy</title> | ||
<link rel="stylesheet" href="demo.css" /> | ||
</head> | ||
<body> | ||
<div class="app"> | ||
<nav class="navbar"> | ||
<div class="container"> | ||
<div class="navbar-brand"> | ||
<h1> | ||
<a href="">Simple Scrollspy</a> | ||
</h1> | ||
</div> | ||
|
||
<div class="menu" id="main-menu"> | ||
<a class="menu-item" href="#section-1">Section 1</a> | ||
<a class="menu-item" href="#section-2">Section 2</a> | ||
<a class="menu-item" href="#section-3">Section 3</a> | ||
<a class="menu-item" href="#section-4">Section 4</a> | ||
</div> | ||
</div> | ||
</nav> | ||
|
||
<section class="section" id="hero">Hero</section> | ||
<section class="section scrollspy" id="section-1">Section 1</section> | ||
<section class="section scrollspy" id="section-2">Section 2</section> | ||
<section class="section scrollspy" id="section-3">Section 3</section> | ||
<section class="section scrollspy" id="section-4">Section 4</section> | ||
<section class="section" id="section-5">Section 5</section> | ||
|
||
<footer class="footer"> | ||
<div class="container"> | ||
<p> | ||
<a | ||
href="https://github.com/huukimit/simple-scrollspy" | ||
title="Fork me on Github" | ||
> | ||
Simple Scrollspy - Github | ||
</a> | ||
</p> | ||
</div> | ||
</footer> | ||
</div> | ||
|
||
<script async src="dist/simple-scrollspy.min.js"></script> | ||
<script defer> | ||
window.onload = function () { | ||
scrollSpy("#main-menu", { | ||
sectionClass: ".scrollspy", | ||
menuActiveTarget: ".menu-item", | ||
offset: 100, | ||
// scrollContainer: null, | ||
// smooth scroll | ||
smoothScroll: true, | ||
smoothScrollBehavior: function (element) { | ||
console.log('run "smoothScrollBehavior"...', element); | ||
element.scrollIntoView({ behavior: "smooth" }); | ||
}, | ||
onActive: (el) => { | ||
console.log('run "onActive"...', el); | ||
}, | ||
}); | ||
}; | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.