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 🙏

© 2025 – Pkg Stats / Ryan Hefner

vz-scroll-interactions

v1.0.1

Published

A lightweight, universal scroll interaction library that works with any framework - vanilla JS, React, Vue, and more

Readme

VZ Scroll Interactions

A lightweight, universal scroll interaction library that works with any framework - vanilla JavaScript, React, Vue, Angular, and more. Create smooth scroll-triggered animations with minimal setup.

Features

  • 🚀 Universal: Works with any framework or vanilla JavaScript
  • 🪶 Lightweight: Minimal footprint with no dependencies
  • Performance: Optimized scroll handling with built-in throttling
  • 🎯 Precise: Advanced trigger point calculations
  • 🧹 Clean: Automatic cleanup and memory management
  • 📱 Responsive: Built-in viewport width tracking

Installation

npm install vz-scroll-interactions

Quick Start

Vanilla JavaScript

import scrollTrigger from 'vz-scroll-interactions';

const element = document.querySelector('.my-element');

scrollTrigger.createInstance('fade-in', element, {
  values: [[0, 1]], // Animate from 0 to 1
  startPoint: [0.8], // Start when element is 80% in viewport
  endPoint: [0.2], // End when element is 20% in viewport
  callback: ({ v }) => {
    element.style.opacity = v[0];
  }
});

React

import { useEffect, useRef } from 'react';
import scrollTrigger from 'vz-scroll-interactions';

function AnimatedComponent() {
  const elementRef = useRef();

  useEffect(() => {
    const instance = scrollTrigger.createInstance('slide-in', elementRef, {
      values: [[100, 0]], // Slide from 100px to 0px
      callback: ({ v }) => {
        elementRef.current.style.transform = `translateX(${v[0]}px)`;
      }
    });

    return () => {
      scrollTrigger.removeInstance('slide-in');
    };
  }, []);

  return <div ref={elementRef}>Animated content</div>;
}

Vue

import { ref, onMounted, onUnmounted } from 'vue';
import scrollTrigger from 'vz-scroll-interactions';

export default {
  setup() {
    const elementRef = ref();

    onMounted(() => {
      scrollTrigger.createInstance('rotate', elementRef, {
        values: [[0, 360]], // Rotate from 0 to 360 degrees
        callback: ({ v }) => {
          elementRef.value.style.transform = `rotate(${v[0]}deg)`;
        }
      });
    });

    onUnmounted(() => {
      scrollTrigger.removeInstance('rotate');
    });

    return { elementRef };
  }
};

API Reference

Main Methods

createInstance(key, element, options)

Creates a new scroll interaction instance.

Parameters:

  • key (string): Unique identifier for the instance
  • element (HTMLElement | Ref): Target element or React/Vue ref
  • options (object): Configuration options

Options:

{
  values: [[startValue, endValue]], // Array of value pairs to animate
  startPoint: [0.5], // When animation starts (0-1, viewport percentage)
  endPoint: [0.5], // When animation ends
  callback: ({ v, ref, vw, start, end }) => {}, // Animation callback
  unrestrictedCallback: ({ ref, vw }) => {}, // Always-called callback
  isUnrestricted: false // Whether to use unrestricted mode
}

removeInstance(key)

Removes a scroll interaction instance and cleans up resources.

toggleInstance(key, enabled)

Enables or disables a specific instance without removing it.

Advanced Methods

calcTop(element, customStart)

calcBot(element, customEnd)

distance(element)

calcPercent(start, end, current)

calcCurrent(start, end, percentage)

Utility methods for custom calculations.

Global Configuration

setVzSIFactor(factor)

Sets a global scaling factor for all calculations (useful for responsive designs).

import { setVzSIFactor } from 'vz-scroll-interactions';

// Scale all calculations by 0.8
setVzSIFactor(0.8);

Advanced Usage

Multiple Value Animations

scrollTrigger.createInstance('complex-animation', element, {
  values: [
    [0, 100],    // First value: 0 to 100
    [1, 0],      // Second value: 1 to 0
    [0, 360]     // Third value: 0 to 360
  ],
  callback: ({ v }) => {
    element.style.transform = `translateX(${v[0]}px) scale(${v[1]}) rotate(${v[2]}deg)`;
  }
});

Custom Trigger Points

// Start when element top hits 80% of viewport
// End when element bottom hits 20% of viewport
scrollTrigger.createInstance('custom-trigger', element, {
  startPoint: [0.8],
  endPoint: [0.2],
  values: [[0, 1]],
  callback: ({ v, start, end }) => {
    console.log(`Progress: ${v[0]}, Start: ${start}, End: ${end}`);
  }
});

Responsive Animations

scrollTrigger.createInstance('responsive', element, {
  values: [[0, 100]],
  callback: ({ v, vw }) => {
    // Different animations based on viewport width
    if (vw <= 768) {
      element.style.transform = `translateY(${v[0]}px)`;
    } else {
      element.style.transform = `translateX(${v[0]}px)`;
    }
  }
});

Browser Support

  • Modern browsers (ES6+)
  • IE11+ (with polyfills)
  • Mobile browsers
  • Server-side rendering safe

Performance Tips

  1. Reuse instances when possible instead of creating new ones
  2. Use throttling for heavy animations
  3. Clean up instances when components unmount
  4. Batch DOM updates in your callbacks

License

MIT License - see LICENSE file for details.

Contributing

Contributions welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.

Support