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-scrolltie

v1.0.3

Published

a jQuery plugin that ties a CSS property to user scroll

Downloads

160

Readme

ScrollTie

###a jQuery plugin that ties a CSS property to scroll###

Build Status

Supports modern browsers and IE9+ (could be modified to support IE8 but need seems too small)

This plugin is useful for creating parallax motion or similar effects in which a CSS property needs to be incremented on user scroll. Here are a handful sites currently using ScrollTie (some are using previous (unreleased) versions):

If you're using ScrollTie on a project, please email [email protected] when it's live so that we can include it here (with permission)!

Get ScrollTie

####Via npm:####

npm install jquery-scrolltie

####Via bower: ####

bower install jquery-scrolltie

####DIY#### Download or clone repo and include js/dist/scrollTie.min.js (unminified version available as well)

ScrollTie depends on jQuery - be sure to include a stable version before the plugin script. Tested with latest stable version 1 and 2.

Usage

Call scrollTie on any valid jQuery object and pass it options. The only required option is property, which can point to any increment-able CSS property. There are supported shorthands for 2D transforms, backgroundPositionX, and backgroundPositionY.

Example:

$('.scroll-tied-element').scrollTie({
    property: 'translateX'
})

Options

property

string (required) CSS property or one of the following supported shorthands:

  • 'translateX'
  • 'translateY'
  • 'scale'
  • 'rotate'
  • 'backgroundPositionX'
  • 'backgroundPositionY'
  • 'opacity'

speed

number (default: 1) Relative to speed of scroll, where 1 moves at speed of scroll, and 2 moves twice as fast as speed of scroll

stopAtValue

number or function When the property is incremented to this value, stop moving element. Function option must return a number.

reverseDirection

boolean (default: false) Decrease property value on scroll.

delay

number or function Distance past the bottom of the viewport to wait before beginning to increment property. Functions are passed a reference to the dom element and must return a number.

Example:

function(el) {
    return $(el).height() * 2;
}

propertyValueFormat

function Provide your own formatting for special properties that are don't have built-in support, such as 3D transforms, or override the format for custom behavior. This function is called on update and should be used with care. This function must return a string which will be used as the value of the specified property. The example below is the built-in propertyValueFormat for transform: translateX().

function(moveValue, element) {
    return 'translateX(' + moveValue + 'px)';
}

context

selector (default: window) Specify a scrolling context

manualInit

boolean (default:false) Wait for manual call to initialize scrollTie

Callbacks

All callback functions are passed the dom element as an argument.

Format:


function(element) {
    // your callback
}

afterStop

function Called every time element reaches its stopAtValue

onPause

function Called when element is manually paused

onStart

function Called when element is restarted after it has been paused

onDestroy

function Called when scrollTie instance is destroyed

Public Methods


// To affect single instance:
$('.scroll-tied-element').scrollTie('method');

// To affect all instances:
$.scrollTie('method');

init

Call once if option manualInit is set to true to begin incrementing property value on scroll.

pause

Call pause to temporarily stop incrementing property value. You must call $('.scroll-tied-element').scrollTie('restart') to continue incrementing.

restart

Call restart after pause to begin incrementing again.

** NOTE: Pause and Restart will take elements out of the flow so that they will not necessarily end back where they began. Use with care! **

destroy

Destroys and removes all plugin data.

refresh

Recalculate offsets, delays, and element positions - useful for when the dom changes asynchronously. This is called internally on window resize.

Testing

To test, you will need to run npm install to get test library packages. Current test suite is located in the tests directory.

Open the tests/index.html file in your web browser to run the tests.

Contribution guidelines

Log an issue, fork the repo, and create a pull request. Include Issue # and change details in the commit.

Changelog

v1.0.0

  • Initial release.

v1.0.1

  • Allow function to be passed in for stopAtValue option

v1.0.2

  • Fix UMD by adding jquery as a dependency in all environments.

v1.0.3

  • Wait until first animate request to calculate static transform value