Giter VIP home page Giter VIP logo

affixed's Introduction

Affixed

MIT licensed

Make something affix on scroll.

Usage

// es6 imports
import affixed from 'affixed';

// commonjs
// var affixed = require('affixed');

var menu = new affixed({
  element: document.getElementById('sticky-menu'),
  offset: 70,
  position: 'fixed',
  throttle: 10,
});
<div id="sticky-menu">
  ... content here
</div>

Parameters

Param Description
element The DOM element to affix.
offset Amount of pixels to scroll before the element is affixed.
position Either absolute fixed, or mirror positioning.
throttle Specify the milliseconds to throttle the position updates.

Notes

absolute positioned element's are reposition on every scroll which may perform slow in some instances. You should set the position to fixed whenever possible. If your element is within a container that is positioned relative, you will need to set the position parameter to absolute.

You can also choose to use the mirror position option. A mirror will be created and added to the <body/> element as a clone of your specified element. This mirror will now act as the affixed element.

Lint

$ npm run lint

Dev

$ npm run dev

Build

$ npm run build

License

MIT © Vu Tran

affixed's People

Contributors

vutran avatar yurimalheiros avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

taml pickwei

affixed's Issues

Add MIT license badge.

Add MIT license badge (from shields.io) underneath the title and above the description.

Please refer to Dext for example and placement.

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.