Socket
Book a DemoInstallSign in
Socket

react-simple-affix

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-simple-affix

A simple react component that sticks to the viewport when scrolling until it reaches its relative element bottom point.

1.0.7
latest
Source
npmnpm
Version published
Weekly downloads
21
61.54%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

affix

FAQs

Package last updated on 30 Dec 2023

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.