1.0.7 • Published 4 months ago

react-simple-affix v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

React Affix

GitHub issues GitHub license

React Affix is a component that sticks to the viewport when scrolling until it reaches its relative element bottom point.

Installation

npm i react-simple-affix

Usage

import Affix from 'react-simple-affix'

<Affix fixedNavbarSelector="#my-navbar" relativeElementSelector="#main-content">
  <ul>
    <li><a href="/home">Home</a></li>
    <li><a href="/about">About</a></li>
    <li><a href="/about">Contact</a></li>
  </ul>
  ...
</Affix>

Demo

Props

NameRequiredTypeDescription
enabledoptionalbooleanenable/disable affix
relativeElementSelectoroptionalstringselector of an element that would determine the floating stop point of affix. Default: Parent Element
fixedNavbarSelectoroptionalstringselector of fixed navbar element; Affix will avoid to overlap it. (only applicable for fixed navbar)
fixedFooterSelectoroptionalstringselector of fixed footer element; Affix will avoid to overlap it. (only applicable for fixed footer)
topOffsetoptionalnumbertop offset of affix from viewport. Default: 15
bottomOffsetoptionalnumberbottom offset of affix from viewport. Default: 15
inheritParentWidthoptionalbooleanshould affix follow the width of parent when its position is fixed. Default: true

Determining Relative Element

Relative element's height serves as the reference of affix to determine when it will stop floating.

Example: if you have a main and side div, you can make the main div as the relative element...
with this setup, affix would follow the height of main and will stop floating if the end of main div is reached

1.0.7

4 months ago

1.0.6

9 months ago

1.0.5

1 year ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago