Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cferdinandi/sticky-footer
Dynamic, responsive sticky footers.
https://github.com/cferdinandi/sticky-footer
footer javascript javascript-plugin no-dependencies sticky-footer vanilla-js
Last synced: 3 months ago
JSON representation
Dynamic, responsive sticky footers.
- Host: GitHub
- URL: https://github.com/cferdinandi/sticky-footer
- Owner: cferdinandi
- License: mit
- Created: 2014-08-15T21:13:07.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-04-03T18:56:13.000Z (almost 8 years ago)
- Last Synced: 2024-10-09T15:01:10.803Z (3 months ago)
- Topics: footer, javascript, javascript-plugin, no-dependencies, sticky-footer, vanilla-js
- Language: JavaScript
- Homepage:
- Size: 47.9 KB
- Stars: 48
- Watchers: 8
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Sticky Footer [![Build Status](https://travis-ci.org/cferdinandi/sticky-footer.svg)](https://travis-ci.org/cferdinandi/sticky-footer)
Responsive sticky footers that adjust dynamically as the screen size changes.[Download Sticky Footer](https://github.com/cferdinandi/sticky-footer/archive/master.zip) / [View the demo](http://cferdinandi.github.io/sticky-footer/)
### Want to learn how to write your own vanilla JS plugins? Check out ["The Vanilla JS Guidebook"](https://gomakethings.com/vanilla-js-guidebook/) and level-up as a web developer. 🚀
## Getting Started
Compiled and production-ready code can be found in the `dist` directory. The `src` directory contains development code.
### 1. Include Sticky Footer on your site.
```html
```
### 2. Add the markup to your HTML.
```html
Body content
Footer content
```Add the `data-sticky-wrap` attribute to a parent `
` that contains all of your page content. Add the `data-sticky-footer` attribute to the parent `` that contains all of your footer content.### 3. Initialize Sticky Footer.
```html
stickyFooter.init();
```
In the footer of your page, after the content, initialize Sticky Footer. And that's it, you're done. Nice work!
## Installing with Package Managers
You can install Sticky Footer with your favorite package manager.
* **NPM:** `npm install cferdinandi/sticky-footer`
* **Bower:** `bower install https://github.com/cferdinandi/sticky-footer.git`
* **Component:** `component install cferdinandi/sticky-footer`## Working with the Source Files
If you would prefer, you can work with the development code in the `src` directory using the included [Gulp build system](http://gulpjs.com/). This compiles, lints, and minifies code.
### Dependencies
Make sure these are installed first.* [Node.js](http://nodejs.org)
* [Gulp](http://gulpjs.com) `sudo npm install -g gulp`### Quick Start
1. In bash/terminal/command line, `cd` into your project directory.
2. Run `npm install` to install required files.
3. When it's done installing, run one of the task runners to get going:
* `gulp` manually compiles files.
* `gulp watch` automatically compiles files when changes are made and applies changes using [LiveReload](http://livereload.com/).## Options and Settings
Sticky Footer includes smart defaults and works right out of the box. But if you want to customize things, it also has a robust API that provides multiple ways for you to adjust the default options and settings.
### Global Settings
You can pass callbacks into Sticky Footer through the `init()` function:
```javascript
stickyFooter.init({
selectorWrap: '[data-sticky-wrap]', // Selector for the wrap container (must use a valid CSS selector)
selectorFooter: '[data-sticky-footer]', // Selector for the footer (must use a valid CSS selector)
callback: function () {}, // Runs after the footer is stuck
});
```### Use Sticky Footer events in your own scripts
You can also call Sticky Footer events in your own scripts.
#### destroy()
Destroy the current `stickyFooter.init()`. This is called automatically during the `init` function to remove any existing initializations.```javascript
stickyFooter.destroy();
```## Browser Compatibility
Sticky Footer works in all modern browsers, and IE 9 and above.
Sticky Footer is built with modern JavaScript APIs, and uses progressive enhancement. If the JavaScript file fails to load, or if your site is viewed on older and less capable browsers, footers will simply float up against the content like they normally would.
## How to Contribute
In lieu of a formal style guide, take care to maintain the existing coding style. Please apply fixes to both the development and production code. Don't forget to update the version number, and when applicable, the documentation.
## License
The code is available under the [MIT License](LICENSE.md).