Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.davist11:jQuery-One-Page-Nav:'
}
dependencies {
implementation("com.github.davist11:jQuery-One-Page-Nav:")
}
<dependency>
<groupId>com.github.davist11</groupId>
<artifactId>jQuery-One-Page-Nav</artifactId>
<version></version>
</dependency>
libraryDependencies += "com.github.davist11" % "jQuery-One-Page-Nav" % ""
:dependencies [[com.github.davist11/jQuery-One-Page-Nav ""]]
A lightweight jQuery plugin for the navigation on one-page sites. Adds smooth scrolling when clicking on the navigation and automatically selects the correct navigation items as you are scrolling through the different sections.
The plugin still works even if you add additional content to the page after the fact that changes the position of each section.
If you want the hash to change when a user clicks on the navigation, then change the changeHash options to true.
If you want to filter items out of your navigation then pass in a selector to the filter option.
In a previous version, there was an offset option to pass into the JavaScript. This was abandoned in favor of a CSS-only solution which simplified the code and makes it easier to handle responsively. Example
If clicking a link in the nav makes the rest of the links unclickable until you scroll, you can solve it in this hacky way:
<pre>$('#nav').onePageNav({ begin: function() { //Hack so you can click other menu items after the initial click $('body').append('<div id="device-dummy" style="height: 1px;"></div>'); }, end: function() { $('#device-dummy').remove(); } });</pre>Found the solution here