StickyHeaders

A JS library which enables sticky section headers in a scrollable list view.

Demo

Browser Compatibility

API

StickyHeaders has a single instance option to pass during initialization.

Instance Options

Usage

Using StickyHeaders is really simple. It has a pure JavaScript API, plus an optional jQuery plugin.

Vanilla JS

Include the widget on the page.

<!DOCTYPE html>
<html>
  <head>
    <script src="dist/scripts/stickyheaders.min.js"></script>
    <link rel="stylesheet" href="dist/styles/stickyheaders.min.css">
  </head>
</html>

Initialize the widget on the list element.

var list = new StickyHeaders(document.getElementById('movies'), {
  headerSelector: '.movies-genre'
});

jQuery

Include the widget on the page.

<!DOCTYPE html>
<html>
  <head>
    <script src="dist/scripts/stickyheaders.jquery.min.js"></script>
    <link rel="stylesheet" href="dist/styles/stickyheaders.min.css">
  </head>
</html>

Initialize the widget on the list element.

$('movies').stickyHeaders({
  headerSelector: '.movies-genre'
});

Build

StickyHeaders uses npm, bower and gulp.

Initialize the dependencies:

npm install
bower install

Build the project:

gulp

The results will appear in the dist directory.