Coder Social home page Coder Social logo

marmelab / sticky-header Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jpetitcolas/sticky-header

0.0 2.0 0.0 103 KB

An angularjs directive for making headers that don't scroll past the top of the screen.

License: MIT License

JavaScript 100.00%

sticky-header's Introduction

sticky-headers

An AngularJS directive for making headers that won't scroll past the top of the screen.

Demo Page

How to use it

Just include jQuery, Angular, and the sticky-headers JavaScript file in your page. You can also install it using either bower or npm:

bower install fsm-sticky-header

# or

npm install fsm-sticky-header
  <head>
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
	<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular.min.js"></script>
	<script src="https://rawgithub.com/FutureStateMobile/sticky-headers/master/src/fsm-sticky-header.js"></script>
  </head>

Then include the fsm Angular module in your own module:

angular.module('MyHappyModule', ['fsm']);

Then add the directive to the element that you with to stick to the top of the page

  <table ng-app="MyHappyModule" id="testtable">
    <thead>
      <tr fsm-sticky-header scroll-body="#testtable" scroll-stop='50'>
         <th>Column One Header</th>
         <th>Column Two Header</th>
      </tr>
    </thead>
    <tbody>
      <tr>
         <td>table1 data1</td>
         <td>table1 data1</td>
      </tr>
      <tr>
         <td>table1 data2</td>
         <td>table1 data2</td>
      </tr>
      ...
    </tbody>
  </table>

Options

  • scroll-body
    • this is the JQuery selector of the element that your header is bound to. Sticky header will follow the position of that element and keep the header on top of that element as it scrolls off the page.
  • scroll-stop
    • this is how many pixels from the top of the page your elment will stop scrolling at, just in case you have a header on the top of your page.
  • scrollable-container
    • If you have a scrollable element such as a div, rather than the web page body scrolling, you'll need to specify that element id here.

Browser Support

We support the current versions of Chrome, Firefox, Safari, Microsoft Edge and Internet Explorer 10+.

sticky-header's People

Contributors

anthanh avatar chaseflorell avatar cmelo avatar evictor avatar gijskooij avatar hallerpierre avatar ivanrey avatar jpetitcolas avatar keithnlarsen avatar raz-varren avatar rlems avatar vladradulescu1 avatar wodka avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.