npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

f1-sticky

v1.0.6

Published

Simple sticky component for React using Redux

Downloads

9

Readme

f1-sticky

Simple sticky component for React-Redux projects. Allows for a containing panel to have a "sticky" child: when the panel is scrolled down past the child's top it remains at the top of it, allowing the rest of the content to scroll.

Install

npm i f1-redux-fixed --save

Usage

In the containing component (the overflowing container):

import { StickyParent } from 'f1-sticky'

const Parent = () =>
    <StickyParent updateRate={10}>
        {/* some content... */}
        <Content />
    </StickyParent>

updateRate is optional but can be specified to limit the # of updates per second. It will slightly delay the component becoming "sticky" but can improve performance on an app with a lot of components.

The parent needs to be the positioning anchor for the sticky child (i.e., position: relative)

In the child component:

import { StickyChild } from 'f1-sticky'

const Child = () =>
    <StickyChild>
      <SomeElement />
    </StickyChild>

You also need to include the reducer when you create your store:

import {reducer as stickyReducer} from 'f1-sticky'

const store = createStore(combineReducers({
  sticky: stickyReducer
  // ... other reducers ...
}))

Putting it together (see also the example in the example folder):

import React from 'react'

import {StickyParent, StickyChild} from 'f1-sticky'

const App = () =>
  <div className="outer">
    <div className="left">
      I am left bar
    </div>
    <main>
      <div className="search-bar">
        I am top bar. I stay visible.
      </div>
      <div className="content">
        <StickyParent className="scroller">
          <div className="filterbar">I am filter. I hide when we start scrolling</div>
          <StickyChild><div className="innersticky">I am sticky</div></StickyChild>
          <div className="placeholder"></div>
          <div className="bottom">I am not sticky</div>
        </StickyParent>
      </div>
    </main>
  </div>

Limitations

  • You cannot currently have 2 sticky children. Put them both under the same container.
  • If you have more than 1 sticky parent / child in your page, you need to give them different names (pass a name prop to both parent and child)
  • There is a react-sticky component that has a lot more options but is more complex and does not work well for a component that is positioned relative to a container that is itself positioned relative to another one.

Development

  • Use npm start to start a sample page
  • Use npm test to run the tests