New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

scrollq

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scrollq

Lightweight scroll-triggered animations using Intersection Observer API

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

ScrollQ

Lightweight, dependency-free scroll animations using the Intersection Observer API. Simple, performant, and highly customizable.

Features

  • 🪶 Lightweight - 1.6KB JS + 1.5KB CSS minified
  • Performant - Native Intersection Observer API
  • 🎨 Flexible - 10 animation variants with full customization
  • Accessible - Respects prefers-reduced-motion

Installation

npm install scrollq

Quick Start

<link rel="stylesheet" href="node_modules/scrollq/dist/scrollQ.min.css" />
<script type="module">
  import { initScrollQ } from "scrollq";
  initScrollQ();
</script>

<!-- Add animations -->
<div data-q="fade-up">Animates on scroll</div>
<div data-q="slide-left" data-q-delay="200">Delayed animation</div>

Global Configuration

initScrollQ({
  threshold: 0.5, // When element is 50% visible (0-1)
  reverse: false, // Enable reverse animations
  rootMargin: "-50px", // Offset trigger area
  duration: "0.6s", // Default animation duration
  easing: "ease-out", // Default timing function
  fromY: "7rem", // Default vertical distance
  fromX: "7rem", // Default horizontal distance
  selector: "[data-q]", // Custom selector
});

Cleanup (SPAs)

Option 1: Cleanup specific instance

const cleanup = initScrollQ();
// Later, when component unmounts:
cleanup();

Option 2: Cleanup all instances globally

import { initScrollQ, destroyScrollQ } from "scrollq";

initScrollQ();
// Later, to clean up everything:
destroyScrollQ();

Animations

TypeDescription
fadeSimple fade in
fade-upFade in from below
fade-downFade in from above
fade-leftFade in from right
fade-rightFade in from left
scaleFade + scale up
slide-upSlide from below (no fade)
slide-downSlide from above (no fade)
slide-leftSlide from right (no fade)
slide-rightSlide from left (no fade)

Customization

Element Attributes

AttributeDefaultDescription
data-q-Animation type (required)
data-q-threshold0.5Trigger visibility (0.0-1.0)
data-q-offset-Viewport offset (%, px, vh, rem)
data-q-from7remAnimation distance
data-q-duration0.6sAnimation duration
data-q-easingease-outTiming function
data-q-delay-Delay in milliseconds
data-q-reversefalseReverse on scroll up

CSS Variables

:root {
  --q-duration: 0.8s;
  --q-easing: cubic-bezier(0.4, 0, 0.2, 1);
  --q-from-y: 5rem;
  --q-from-x: 5rem;
}

Examples

Staggered list:

<ul>
  <li data-q="fade-up" data-q-delay="100">First</li>
  <li data-q="fade-up" data-q-delay="200">Second</li>
  <li data-q="fade-up" data-q-delay="300">Third</li>
</ul>

Trigger at viewport middle:

<div data-q="fade-up" data-q-offset="-50%">Centered trigger</div>

Reverse animations:

<div data-q="scale" data-q-reverse>Reverses when scrolling up</div>

Custom animation:

<div data-q="fade-up" data-q-from="10rem" data-q-duration="1s" data-q-easing="ease-in-out">
  Smooth long-distance fade
</div>

How It Works

ScrollQ uses the Intersection Observer API to watch elements. When visible, it adds the q-active class to trigger CSS transitions.

Behavior:

  • Animations trigger when scrolling down and element enters from bottom
  • With data-q-reverse, animations reverse when scrolling up
  • Elements already scrolled past are automatically activated on page load
  • Respects prefers-reduced-motion for accessibility

Browser Support

Chrome 51+, Firefox 55+, Safari 12.1+, Edge 15+

Development

npm install
npm run build  # Builds dist files

File sizes: 1.6KB JS + 1.5KB CSS (minified)

License

MIT License - feel free to use in personal and commercial projects.

Credits

Created by Kevin Terry

Inspired by AOS and the need for a super simple, modern scroll animation solution.

Keywords

scroll

FAQs

Package last updated on 06 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts