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

parker.js

v1.3.4

Published

A js module for making elements 'sticky'

Downloads

4

Readme

Parker.js

Make things sticky

Hey web slingers! Parker.js is a small script for making elements sticky.

Parker.js lets you target a given element and will make it stick in place once the bottom of that element scrolls into view. It will unstick it, allowing it to continue scrolling normally, once the bottom of its parent element scrolls to the position of the bottom of the sticky element. The same is true of the tops of the elements when scrolling up.

Installing

Install parker.js with Yarn

yarn add parker.js

and import the parker module

import parker from "parker.js"

Usage

Kick off parker.js with it's init method:

parker.init(selector, options)

Parker.js takes a selector of the element that is to be make sticky. If parker cannot find an element that matches the selector it will fail silently. If there are multiple elements that match the given selector it will just use the first one.

In addition to the selector, parker.js accepts an options object which can include the following options:

Options:

parentSelector: The sticky element will stay in place until the top or bottom of the parent element touches the top or bottom of the sticky element. By default parker.js can infer the parent of the element that is being made sticky. If, however, you would prefer to treat a grandparent or an element higher up the stack as the parent you can set a selector here to have the sticky element remain in place until that element touches the top or bottom of the sticky element.

Using sibling or a different element within which the sticky element is not contained, can cause some… interesting behavior.

breakpointStart It doesn't typically make sense to make elements sticky at narrow breakpoints. By default, elements will retain standard behavior until the window is wider than 768px. If you'd like to change this you can pass the value of the desired width in pixels.

bottomMargin By default parker.js does not add any margin between the sticky element and the parent. A pixel value can be set here to provide some buffer between the bottom of the sticky element and the bottom of the parent element.

widthReferenceSelector By default parker.js keep the sticky element as wide as it is on the initial page load. For responsive or variable width elements, this can cause some weirdness if and when the browser is resized. To solve this issue, parker.js can take a selector of a different element on the page and use its width for the sticky element's width as the window size changes.

Tidy Up:

In addition to the init method, parker.js also provides a tidyUp method to make sure that the element is unstuck and any event listeners are removed. This method takes no arguments:

parker.tidyUp();

Examples:

parker.init('.parker', {
  parentSelector: '.parker-parent',
  breakpointStart: 800,
  bottomMargin: 50
});