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

sticky-sidebar-v3

v1.1.2

Published

A JavaScript plugin for making smart and high performance sticky sidebars.

Downloads

114

Readme

Sticky Sidebar v2 Build Status

Pure JavaScript plugin for making smart and high performance sticky sidebars, originally written by Ahmed Bouhuolia.

Why the fork?

This project was forked from the original Sticky Sidebar, written by Ahmed Bouhuolia. As the original project is currently inactive, this fork is an attempt to revive the project and add some improvements.

Examples

Basic Example

Scrollable Sticky Element

For complete documentation and examples see blixhavn.github.com/sticky-sidebar-v2

Why is sticky sidebar so awesome?

  • It does not re-calculate all dimensions when scrolling, just necessary dimensions.
  • Super smooth without incurring scroll lag or jank and no page reflows.
  • It has event trigger on each affix type to hook your code under particular situation.
  • Handle the sidebar when is tall or too short compared to the rest of the container.
  • Zero dependencies and super simple to setup.

Install

You can download sticky sidebar v2 vjQuery plugin from Yarn, NPM or just simply download it from this page and link to the sticky-sidebar.js file in your project folder.

Yarn

If you are using Yarn as package manager:

yarn add sticky-sidebar-v2

NPM

If you are using NPM as package manager:

npm install sticky-sidebar-v2

Usage

Your website's html structure has to be similar to this in order to work:

<div class="main-content">
    <div class="sidebar">
        <div class="sidebar__inner">
            <!-- Content goes here -->
        </div>
    </div>
    <div class="content">
        <!-- Content goes here -->
    </div>
</div>

Note that inner sidebar wrapper .sidebar__inner is optional but highly recommended, if you don't write it yourself, the script will create one for you under class name inner-wrapper-sticky. but this may cause many problems.

If your content is inside a fixed-height div with a scrollbar, this must be specified with the scrollContainer option.

For the above example, you can use the following JavaScript:

<script type="text/javascript" src="./js/sticky-sidebar.js"></script>

<script type="text/javascript">
  var sidebar = new StickySidebar('.sidebar', {
    topSpacing: 20,
    bottomSpacing: 20,
    containerSelector: '.main-content',
    innerWrapperSelector: '.sidebar__inner',
    scrollContainer: '#main-viewport'
  });
</script>

Via jQuery/Zepto

You can configure sticky sidebar as a jQuery plugin, just include jquery.sticky-sidebar.js instead sticky-sidebar.js file than configure it as any jQuery plugin.

<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/jquery.sticky-sidebar.js"></script>

<script type="text/javascript">
  $('#sidebar').stickySidebar({
    topSpacing: 60,
    bottomSpacing: 60
  });
</script>

Make sure to include sticky-sidebar.js script file after jquery.js.

Browser Support

Sticky Sidebar v2 works in all modern browsers including Internet Explorer 9 and above, but if you want it to work with IE9, should include requestAnimationFrame polyfill before sticky sidebar code. For backwards compatibility, a polyfill for ResizeObserver can also be included.

If you have any issues with browser compatibility don’t hesitate to Submit an issue.

License

Sticky Sidebar v2 is released under the MIT license. Have at it.


Maintained by Øystein Blixhavn

Originally made by Ahmed Bouhuolia