All Projects → ShiraNai7 → jquery-scrollwatch

ShiraNai7 / jquery-scrollwatch

Licence: MIT license
jQuery plugin for determining active sections on the page based on scrolling

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to jquery-scrollwatch

angular-scrollspy
A simple lightweight library for Angular which automatically updates links to indicate the currently active section in the viewport
Stars: ✭ 34 (+88.89%)
Mutual labels:  navigation, scrolling
Jquery.localscroll
Animated anchor navigation made easy with jQuery
Stars: ✭ 624 (+3366.67%)
Mutual labels:  navigation, scrolling
EasyScrollDots
Single page scroll JavaScript plugin that allows for vertical navigation of page sections
Stars: ✭ 38 (+111.11%)
Mutual labels:  navigation, scrolling
Gumshoe
A simple vanilla JS scrollspy script.
Stars: ✭ 640 (+3455.56%)
Mutual labels:  navigation, scrolling
Tlyshynavbar
Unlike all those arrogant UINavigationBar, this one is shy and humble! Easily create auto-scrolling navigation bars!
Stars: ✭ 3,780 (+20900%)
Mutual labels:  navigation, scrolling
Priority Nav Scroller
Priority Nav Scroller is a plugin for the priority+ navigation pattern.
Stars: ✭ 198 (+1000%)
Mutual labels:  navigation, scrolling
motion-planner-reinforcement-learning
End to end motion planner using Deep Deterministic Policy Gradient (DDPG) in gazebo
Stars: ✭ 99 (+450%)
Mutual labels:  navigation
hipsbarjs
Hipsbarjs is a javascript plugin for easily creating drawers in web apps
Stars: ✭ 17 (-5.56%)
Mutual labels:  navigation
Router
Router is a library that assists with SwiftUI view transitions.
Stars: ✭ 68 (+277.78%)
Mutual labels:  navigation
FoxBarcodeQR
FoxBarcodeQR is a supplement of FoxBarcode class only for QR Code barcodes. This class is an alternative solution for all developers who requested QR Code support.
Stars: ✭ 20 (+11.11%)
Mutual labels:  class
diractions
👨‍💻 Doing Anything, Anywhere, from Here [zsh] 🚏
Stars: ✭ 30 (+66.67%)
Mutual labels:  navigation
navigation array
Helper function for building navigations for REDAXO cms
Stars: ✭ 22 (+22.22%)
Mutual labels:  navigation
java-class-tools
Read and write java class files in Node.js or in the browser.
Stars: ✭ 27 (+50%)
Mutual labels:  class
vscode-tree-view
VSCode extension that probvides mail symbol overview of the currently opened file
Stars: ✭ 26 (+44.44%)
Mutual labels:  navigation
vue-bottom-navigation
Vue bottom navigation
Stars: ✭ 56 (+211.11%)
Mutual labels:  navigation
navigator
Annotation processor that eliminates navigation and Bundle boilerplate
Stars: ✭ 13 (-27.78%)
Mutual labels:  navigation
js-class-is
Enhances a JavaScript class by adding an is<Class> property to compare types between realms.
Stars: ✭ 17 (-5.56%)
Mutual labels:  class
NoobScroll
A lightweight jQuery Plugin that add some cool function to make scrolling more fun [Archive]
Stars: ✭ 43 (+138.89%)
Mutual labels:  scrolling
zoom-drive-connector
Automatically uploads Zoom meeting recordings to Google Drive.
Stars: ✭ 25 (+38.89%)
Mutual labels:  active
bottom-nav
Material Design bottom-nav https://material.io/guidelines/components/bottom-navigation.html
Stars: ✭ 25 (+38.89%)
Mutual labels:  navigation

ScrollWatch

jQuery plugin for determining active sections on the page based on scrolling.

Online demo (latest version)

Features

  • determining active section(s)
  • mapping a class to a list of elements (e.g. menu items)
  • many options, including multiple modes of resolution
  • works with zoom

Requirements

jQuery 1.9.0 or newer

Browser support

Tested in Mozilla Firefox, Google Chrome, Safari, Opera and MSIE 7+.

Usage

The plugin provides two jQuery methods:

Note

If the sections are inside a custom scrollable element, that element must have position: relative, absolute or fixed.

$(sections).scrollWatch(callback[, options])

Attaches a watcher to the given sections. The callback is then invoked when the focus changes, according to options.

  • sections - selector or an array of elements that represent all the possible sections
  • callback - function to invoke when the focus changes
  • options - object with various settings (see list far below)

Callback arguments

$('div.section').scrollWatch(function (focus, view, watcher) {
    // do something with the current focus
});
  1. Object|Object[] focus - the current focus, an object with the following properties:
    (if resolutionMode is none, it will be an array of those objects
    • index - section number (0-based)
    • intersection - null or [y1, y2]
    • section - DOM element of the section
  2. Object view - the current view, an object with the following properties:

    • top - top coordinate of the view
    • bottom - bottom coordinate of the view
  3. Shira.ScrollWatch.Watcher watcher - instance of the current watcher

$(sections).scrollWatchMapTo(items[, activeClass, options])

Attaches a watcher to the given sections and maps the current focus to the respective item using the specified active class.

  • sections - selector or an array of elements that represent all the possible sections
  • items - selector or an array of elements to map the "active class" to
  • activeClass - class name to add to the active item (defaults to "active")
  • options - object with various settings (see list far below)

Example

$('div.section').scrollWatchMapTo('#menu > li');

List of supported options

Option Default Description
scroller null

DOM element to watch for scrolling events.

It must be an HTMLElement or Window.

If no element is given the first found scrollable offset parent or Window will be used instead.

resolutionMode "height"

Determines how the active section is chosen, one of:

  • height - section that is occupying the largest portion of the view is chosen
  • focus-line - section that is directly intersecting or is closest to the focus line is chosen
  • custom - use a custom resolver
  • none - no resolution is performed (all candidates will be passed to the callback)
viewMarginTop 0 Height of an area at the top of the view to be excluded.
viewMarginBottom 0 Height of an area at the bottom of the view to be excluded.
stickyOffsetTop 5 Height of an area at the top of the scroller that, if intersected by the top of the view, forces the first section to be active regardless of other conditions.
stickyOffsetBottom 5 Height of an area at the bottom of the scroller that, if intersected by the bottom of the view, forces the last section to be active regardless of other conditions.
clamp false When enabled, the space between two sections is considered a part of the first section. Useful when there are large gaps between sections.
throttle true

When enabled, the callback is invoked only when the active section changes

When disabled, the callback is invoked on every pulse (e.g. on scroll and resize).

This option has no effect when resolutionMode is none.

Options specific to resolutionMode = height

Option Default Description
topDownWeight 0 Extra focus height added to the section if it precedes the other. This can be used to prefer earlier sections to later ones.
     

Options for resolutionMode = focus-line

Option Default Description
focusRatio 0.3819.. Percentage of the view height that determines position of the focus line.
focusOffset 0

Offset added to position of the focus line position after focusRatio is applied.

Set focusRatio to 0 if you wish to use the focusOffset as an absolute value.

debugFocusLine false

When enabled, position of the focus line will be displayed when scrolling

Intended for debugging purposes.

Options for resolutionMode = custom

Option Default Description
resolver none (required)

Function to invoke when a focus candidate resolution is needed. It must choose and return a single focus object.

The following arguments are passed to the function:

  1. Object[] candidates - an array of focus objects, each object has the following properties:
    • index - section number (0-based)
    • intersection - null or [y1, y2]
    • section - DOM element of the section
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].