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

jquery-sticky-table-header

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

jquery-sticky-table-header

A small and accessible jQuery plugin for adding sticky headers to large data tables.

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
215
increased by8.59%
Maintainers
1
Weekly downloads
 
Created
Source

jquery.stickyTableHeader

A small and accessible jQuery plugin for adding sticky headers to large data tables.

Demo

https://codepen.io/simonsmith/full/yoQyKa/

Features

  • Supports multiple tables on one page
  • Uses position: fixed that allows smooth scrolling and a wide range of browser support
  • Screenreader support
  • Minimal DOM updates in scroll event

Installation

npm

It's recommended to require/import the plugin as part of an existing webpack or browserify setup:

npm install jquery jquery-sticky-table-header --save
// index.js
const $ = require('jquery');
require('jquery-sticky-table-header');
$('.table-container').stickyTableHeader();

Relies on jQuery as a peerDependency so ensure it is installed in your application.

Manual

Clone the repository and run npm install && npm run build. This will generate a UMD version of the plugin in ./build that can be dropped into a project however you want.

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="jquery.stickyTableHeader.js"></script>

Usage

There are a couple of HTML requirements for the plugin to function correctly:

  • The table must be inside a containing element
  • There must be a thead element
  • There must be a tbody element

Example

<div class="table-container">
  <table>
    <thead>
      <!-- content -->
    </thead>
    <tbody>
      <!-- content -->
    </tbody>
  </table>
</div>
$('.table-container').stickyTableHeader();

It's recommended that you apply a background colour to the header to mask the real table header beneath it. This is so that the table effectively looks unchanged to a screen reader.

Options

  • outsideViewportOnly - (boolean) Only run the plugin if the table is larger than the viewport default true
  • scrollThrottle - (number) Maximum number of times the scroll handler can be called over time in milliseconds default 50
  • zIndex - (number) Added to the header to control stacking default 2
  • css (object) Classes applied to the HTML structure
    • header (string) - Added to the header that scrolls with the table default StickyTableHeader
    • scrolling (string) - Added to the header when it is scrolling with the viewport default is-scrolling

Development

  1. Clone the repository
  2. npm install
  3. npm start

Access the demo at http://localhost:3001/example

FAQs

Package last updated on 29 Aug 2017

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