• This repository has been archived on 09/Jun/2021
  • Stars
    star
    1,523
  • Rank 30,762 (Top 0.7 %)
  • Language
    HTML
  • License
    MIT License
  • Created about 14 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Smooth scrolling and smart navigation when user scrolls on one-page sites.

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.

Sample Markup:

<ul id="nav">
	<li class="current"><a href="#section-1">Section 1</a></li>
	<li><a href="#section-2">Section 2</a></li>
	<li><a href="#section-3">Section 3</a></li>
</ul>

<div id="section-1">
	<strong>Section 1</strong>
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>

<div id="section-2">
	<strong>Section 2</strong>
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>

<div id="section-3">
	<strong>Section 3</strong>
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>

Example Usage with Defaults:

$('#nav').onePageNav({
	currentClass: 'current',
	changeHash: false,
	scrollSpeed: 750,
	scrollThreshold: 0.5,
	filter: '',
	easing: 'swing',
	begin: function() {
		//I get fired when the animation is starting
	},
	end: function() {
		//I get fired when the animation is ending
	},
	scrollChange: function($currentListItem) {
		//I get fired when you enter a section and I pass the list item of the 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.

Filter Example:

<ul id="nav">
	<li class="current"><a href="#section-1">Section 1</a></li>
	<li><a href="#section-2">Section 2</a></li>
	<li><a href="#section-3">Section 3</a></li>
	<li><a href="#section-4">Section 4</a></li>
	<li><a href="#section-5">Section 5</a></li>
	<li><a href="http://google.com" class="external">Some other link</a></li>
</ul>

$('#nav').onePageNav({
	filter: ':not(.external)'
});

Offset

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 you are having issues with iOS devices

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:

$('#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();
	}
});

Found the solution here

More Repositories

1

jQuery-Stickem

Make items sticky as you scroll, to a point.
JavaScript
872
star
2

jQuery-Presentation

No need for Keynote or PowerPoint anymore, use a browser to give presentations
JavaScript
118
star
3

YouTube-Chromeless

jQuery YouTube Chromeless Video Plugin
JavaScript
82
star
4

css-diamond-grid

A responsive grid of diamonds.
Ruby
74
star
5

craft-reroute

Manage 301/302 redirects in the control panel.
PHP
60
star
6

craft-shopify

Craft plugin that integrates with the Shopify API
PHP
59
star
7

nested-responsive-grid

Generate a responsive grid that maintains it’s column sizes two levels deep.
Ruby
41
star
8

Image-Scroller

JavaScript
26
star
9

craft-listing-section

PHP
26
star
10

Hon-ee-Pot-Captcha

ExpressionEngine 2.0 Hon-ee Pot Captcha to work with the Freeform module and comment form
PHP
25
star
11

jQuery-Show-Password

Adds a link to toggle the masking of a password input field.
JavaScript
24
star
12

craft-bust

Plugin for Craft to cache bust files
PHP
22
star
13

jQuery-Simple-Validate

Super light-weight jQuery form validation
JavaScript
20
star
14

craft-guzzle

Craft plugin to get a Guzzle response.
PHP
16
star
15

Starter-Template

Super-basic HTML5 starting template
CSS
9
star
16

is-ajax

ExpressionEngine plugin to determine if it's an AJAX request
PHP
8
star
17

fix-ee

A couple of EE CP tweaks
PHP
6
star
18

refresh-dc-compass-sass-presentation

Refresh DC Presentation about Compass and Sass
Ruby
6
star
19

Config-Variables-Plugin

Access ExpressionEngine 2 Config Variables
PHP
4
star
20

EE-Default-CP-Tabs

Add in default tabs for new members
PHP
4
star
21

jQuery-RequiredForm

jQuery form validation plugin for browsers that don't support HTML5 validation.
CSS
3
star
22

trevordavis-remix

TypeScript
3
star
23

ee-simple-preview

ExpressionEngine accessory that adds a preview link to the "preview" page.
PHP
3
star
24

EE-Scroll-To-Comment

ExpressionEngine 2.0: Scroll directly to a new comment after submission
PHP
2
star
25

EE-Multi-Relationship-Checkboxes

Modified version of Mark Huot's Multi Relation extension that uses checkboxes instead of a multi-select
2
star
26

heelp

ExpressionEngine accessory to provide channel specific help on the publish pages.
PHP
2
star
27

HP-Demo

Demo site for presentation
PHP
1
star
28

north-cannabis-co-remix

Not maintained by dutchie, just an quick and dirty exploration using Dutchie+
TypeScript
1
star
29

Gallant

PHP
1
star
30

fedsacrifice

FED Sacrifice Site
JavaScript
1
star
31

dumbwaiter

Chrome Extension to move data from one page to another
JavaScript
1
star
32

segment_category_info

ExpressionEngine plugin to return category info by passing in the category_url_title and channel_short_name.
PHP
1
star