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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-midway-highlighter

v1.4.0

Published

Given a list of react elements, highlight the one which contains the vertical midline of the window.

Downloads

7

Readme

What?

Given a list of vertically stacked non-overlapping elements, this component can be used to find out which element falls in the middle line (midway) of the window.

Once you figure out which element falls on the midway, we can highlight it with different styling.

Why?

Influenced by typeform, I wanted to have a similar functionality in my pluckdp app. So, built it. OSSing it :-)

Example

Clone the repo and open example/index.html in your browser.

It fetches react,react-dom and jquery from script urls and uses jsx in-browser transformer . So, no need to worry about browserifying / reactifying / npming bullshit just to test.

Below is the snap of the example Sample

More details

How does it work?

  • The component encapsulates the children passed with containers.
  • Once, the component is mounted, it will take a note of all containers top & bottom positions. It registers scroll event callback as well.
  • When the window is scrolled, it checks which container the midway falls in and tada!
  • Works with resizing of window as well.

Props?

onActive: React.PropTypes.func This is an optional func prop and the function if passed will be called with a single parameter - index, which is the index of the midway element.

How to style midway element?

Way 1
  • Register onActive callback
  • Style the midway element accordingly in the callback.
Way 2
  • The encapsulating containers have mh_container class.
  • For midway elements, the container's class will have an addition class 'active'.
  • Using this info, you should be able to style.

Dependencies

Depends on react, react-dom and jquery. This component assumes all the global variables already exist.

Why are't they included in package.json

Personally, I think this whole npm js eco-system is screwed up. Or may be am too new to it.

Few points being:

  • My twitter rant
  • Am assuming whoever uses it already have all the dependencies installed / can install dependencies on their own.
  • I spent around 3 hrs making this and being a newbie to this eco system, I spent around 2.5 days trying to fix the interoperability issues of browserify-rails, react-rails + duplicate inclusion of reactjs from some of the dependencies etc.. Thought I will understand and fix it later. Any help here is appreciated.

Open Issues

  • Internally, we register the positions using jQuery .offset(). It has its limitations with margins, which anyways has a work around. I will work on it when I get time.
  • Currently, the component doesn't work well when the children height's change (for eg: with a click). The positions are not updated accordingly.

Contributing

Feel free to send PR.

Any other doubts?

Please create an issue.