AlphaNav

A jQuery plugin that adds a vertically scrolling alphabetical navigation list


Project maintained by triq6 Hosted on GitHub Pages — Theme by mattgraham

Overview

AlphaNav is a simple jQuery plugin that adds a vertical alphabet slider to an alphabetized list. It’s functionality is similar to the iOS Contacts app, and is intended to be used with longer lists, like contacts, countries, etc.

Basic Usage

Make sure that you are loading jQuery and alphaNav.js (or alphaNav.min.js), at some point before calling alphaNav. You should also include the default CSS, or copy the structural CSS into an existing CSS file. A simple example of this:

<script type="text/javascript" src="jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="alphaNav.min.js"></script>
<link rel="stylesheet" href="alphaNav.css" />

All you have to do is call alphaNav on the jQuery object holding the content to scroll, like so:

// Convert #list-content to a scrolling list using the default settings (see below)
$("#list-content").alphaNav();

Actually, it’s not that easy. You’re also going to have to add a class to the list headers (or, if you don’t have list headers, the first element of every new letter). The default header class prefix is .alphanav-header-, but you can change that if you need to. An example of the header class you have to add to your HTML for the letter A would be .alphanav-header-A

If you want to undo everything that alphaNav did, simply call:

$.fn.alphaNav.destroy();

If you want to override any of the default settings, you can either pass them into the alphaNav method:

$('#list-content').alphaNav({
    arrows: false,
    debug: true,
    growEffect: true,
    transitionDuration: 250,
    overlay: true
 });

…OR globally override the defaults; this would be the preferred method if you are using alphaNav in more than one location on your site:

$.fn.alphaNav.defaults.debug = true;
$.fn.alphaNav.defaults.overlay = false;
// Any calls to alphaNav *after* these two lines will have debug = true and overlay = false.

Settings & Defaults

$.fn.alphaNav.defaults = {
    arrows: false,
    autoHeight: true,
    container: null,
    debug: false,
    growEffect: false,
    headerClassPrefix: 'alphanav-header-',
    height: false,
    letters: [
        "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
        "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
    ],
    listSide: 'right',
    onScrollComplete: function () {},
    overlay: true,
    scrollDuration: 500,
    trimList: false,
    trimReplacement: '&#8226;',
    wrapperAttributes: {
        id: 'alphanav-wrapper'
    }
};

Real-world Examples

# TODO #

  1. Sticky letter headers
  2. Make scrolling animation smoother (calls to .stop() behave weird sometimes)
  3. Any recommendations/suggestions?

Metadata

Plugin Name: AlphaNav

Author: triq6

Dependencies: jQuery

Forked from: SliderNav (Original author: Monjurul Dolon)