Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sticky-table-headers

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sticky-table-headers

jQuery sticky table headers plugin

  • 0.1.18
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4K
decreased by-38.9%
Maintainers
1
Weekly downloads
 
Created
Source

StickyTableHeaders

So what's it good for? Well, let's say you want to display a long list of fairly uniform tabluar data, like stock exchange listings or sport statistics but you don't want your users to get lost in the data as they scroll down on the page.

StickyTableHeaders to the rescue: By applying the StickyTableHeaders jQuery plugin to the table, the column headers will stick to the top of the viewport as you scroll down.

Go ahead and try out a demo.

The code is based on this proof of concept.

Installation

The best way to install is using npm;

npm install sticky-table-headers

or Bower:

bower install StickyTableHeaders

Alternatively, you can download the latest version from jquery.stickytableheaders.min.js.

Usage

Initializing the plugin is pretty straight forward:

$('table').stickyTableHeaders();

###Tear down To remove the plugin:

$('table').stickyTableHeaders('destroy');

###Trigger an update manually

$(window).trigger('resize.stickyTableHeaders');

###Options You can initialize the plugin with an options map to tweak the behavior. The following options are supported:

####fixedOffset A number or jQuery object specifying how much the sticky header should be offset from the top of the page:

$('table').stickyTableHeaders({fixedOffset: $('#header')});

####scrollableArea A DOM element or jQuery object. Allows you to overwrite which surrounding element is scrolling. Defaults to window. Check this demo for an example

As described in pull request #33 responsive pages might need to re-initialize the plugin when the user resizes his browser. This is can be done by calling the plugin with the new options:

$('table').stickyTableHeaders({fixedOffset: [new-offset]});

###Events The plugin triggers the following events on the targeted <table> element:

  • clonedHeader.stickyTableHeaders: When the header clone is created.
  • enabledStickiness.stickyTableHeaders: When the sticky header is enabled.
  • disabledStickiness.stickyTableHeaders: When the sticky header is disabled.

Confused?

If any of this is confusing, please check out the /demo folder. There are a couple of examples in there. E.g. you can see how to use it with Twitter Bootstrap.

Known Issues

  • Internet Explorer: You need to set the padding of the <th>s explicitly in the css in order to make the plugin work
  • Internet Explorer: Adding horizontal margin to the table causes the header to be misaligned when scrolling. (Issue #10)
  • Using the plugin together with tablesorter breaks in Internet Explorer 8

Browser Support

The plugin has been verified to work in:

  • Chrome 35
  • Firefox 29
  • Internet Explorer 8-11
  • Safari 5

NOTE: It does not work in Internet Explorer 7 (but it degrades nicely)

Keywords

FAQs

Package last updated on 25 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc