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

jquery.smartheader.js

v1.0.2

Published

Make fixed headers smarter on scroll.

Downloads

10

Readme

jquery.SmartHeader.js Build Status Build Dependencies

Make fixed headers smarter on scroll — disappearing on downwards scroll and reappearing on upwards scroll. Inspired by Teehan+Lax, Readability, and MailChimp. See an example here for a better idea.

SmartHeader - Make your fixed headers smarter on scroll

Basic Usage

Download the production version or the development version.

Or install using a package manager:

// npm
npm install --save jQuery.SmartHeader.js

// bower
bower install --save jQuery.SmartHeader.js

// component
component install lukechesser/jQuery.SmartHeader.js

In your web page:

<script src="jquery.js"></script>
<script src="dist/jQuery.SmartHeader.min.js"></script>
<script>
jQuery(function($) {
  $('.header').smartHeader();
});
</script>

Documentation

Make sure to include jQuery in your page before including SmartHeader.min.js. Calling SmartHeader is easy:

// basic
$('.header').smartHeader();

// custom options
$('.header').smartHeader({
	scrollDownThreshold: 50,
	scrollUpThreshold: 20,
});

// custom options & animations
$('.header').smartHeader({
	scrollDownThreshold: 60,
	scrollUpThreshold: 30,
	animation: {
		onShow: 'bounceInDown',
    	onHide: 'bounceOutUp','
	}
});

Options

  • scrollDownThreshold (pixels): How far the user has to scroll down before the header disappears (in pixels). After the header is hidden, the scrollDownThreshold is reset. Defaults to 30 pixels.

  • scrollUpThreshold (pixels): How far the user has to scroll up before the header reappears (in pixels). After the header is shown, the scrollUpThreshold is reset. Defaults to 5 pixels.

  • headerHeight (pixels): smartHeader automatically detects the height of the header, but if you have a header with a large drop shadow or border, override the height here to make the header (and shadow/border) disappear completely. Defaults to $('.header').height().

  • animation (object/hash): if you want to add your own animations (instead of the default translateY animation), specifiy the onShow and onHide animations here. Defaults to null.

  • animation.onShow (string/CSS class): an animation class to add to the header to reveal the header. Note: for animations to work, you must add an animation duration and animation-fill-mode class to the header directly in the HTML. See more below.

  • animation.onHide (string/CSS class): an animation class to add to the header to hide the header. Note: for animations to work, you must add an animation duration and animation-fill-mode class to the header directly in the HTML. See more below.

Animate

If you want to use a custom animation function, you must specify a general animation class, ex. .animate, in your CSS like this:

.animate {
	animation-duration          : .9s;
	animation-fill-mode         : both;
}

And attach it to your header in your HTML, like this:

...
<div class="header animate">
	...
</div>
...

Look at the custom animation example's raw CSS file and HTML file for more info.

Examples

See a basic example here using the default animation (translateY).

// custom options
$('.header').smartHeader({
	scrollDownThreshold: 40,
	scrollUpThreshold: 10,
});

See a more advanced example here using a custom animation.

// custom animations
$('.header').smartHeader({
	scrollDownThreshold: 60,
	scrollUpThreshold: 20,
	animation: {
		onShow: 'bounceInDown',
    	onHide: 'bounceOutUp','
	}
});

Contributing

I'd love your help, so any contributions are welcome. Feel free to leave a feature request in the issues. If you do submit a pull-request, please follow the etiquette listed below:

  • Please check to make sure that there aren't existing pull requests attempting to address the issue mentioned. We also recommend checking for issues related to the issue on the tracker, as another contributer may be working on the issue in a branch or fork.
  • Non-trivial changes should be discussed in an issue first
  • Develop in a topic branch, not master
  • Squash your commits
  • Write a convincing description of your changes to increase your chances of acceptance

To get your local environment up and running, run npm install and use grunt default to compile and minify assets.

Issues

Before submitting an issue:

  • Make sure you're looking at the latest version
  • Use the search feature to ensure that the issue hasn't been reported before

Please include as much information about the issue as possible.

Contributors