gitwtfhub

wtf is lax.js?

alexfoxy/lax.js — explained in plain English

Analysis updated 2026-06-24

10,487JavaScriptAudience · developerComplexity · 2/5Setup · easy

TL;DR

A tiny JavaScript library under 4KB that adds scroll-triggered animations, fade, slide, spin, inertia, to any web page with no dependencies, using simple class names or a driver-and-element API.

Mindmap

mindmap
  root((lax.js))
    Core concepts
      Drivers
      Elements
      Mappings
      Inertia
    Presets
      Fade in
      Slide
      Spin
    Framework support
      Vanilla HTML
      React
      Vue
    Features
      Breakpoints
      onUpdate callback
      No dependencies

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Add scroll-triggered fade-in and slide effects to a landing page by adding preset class names to HTML elements.

REASON 2

Create animations driven by mouse cursor position or any custom value using the driver API.

REASON 3

Make page elements feel weighted and laggy as the user scrolls using the inertia feature.

REASON 4

Apply different animation behaviors on mobile vs desktop using lax.js breakpoints.

What's in the stack?

JavaScript

How it stacks up

alexfoxy/lax.jsleecade/react-native-swiperwangrongding/wechat-bot
Stars10,48710,49310,501
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasyeasymoderate
Complexity2/52/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min

Wtf does this do

lax.js is a small JavaScript library (under 4 kilobytes when compressed) that adds scroll-triggered animations to web pages without requiring any other libraries or frameworks. When a visitor scrolls down a page, elements can fade in, slide sideways, spin, or shift in any direction, all controlled by how far the page has scrolled. The core idea is a "driver and element" model. A driver is any value that changes over time, most commonly the vertical scroll position of the page but also mouse cursor position, time of day, or anything else you can express as a number. You attach that driver to page elements and define how a CSS property like opacity, translateX, or rotation should change as the driver value changes. The library calculates a mapping between the driver number and the visual output number every frame, so the animation stays in sync with whatever is driving it. For developers who want quick results without writing custom mappings, the library ships with presets that you apply by adding class names directly to HTML elements. A single class name like lax_preset_fadeIn can make an element fade in as it scrolls into view. Multiple presets can be stacked on one element. An interactive preset explorer is linked in the documentation for browsing the available effects. Version 2.0 was a complete rewrite that added inertia, which makes elements feel like they have weight and lag slightly behind the scroll movement before catching up. It also added breakpoints so animations can behave differently on small versus large screens, and an onUpdate callback that fires every frame with the current driver values, useful for toggling CSS classes or updating text based on scroll position. The library works with plain HTML pages and also with React, Vue, and other component frameworks, though those require calling the add and remove element methods when components mount and unmount rather than relying on the initial page load scan.

Yoink these prompts

Prompt 1
I want to add a scroll-triggered fade-in to my hero section using lax.js. Show me the minimal HTML and JavaScript setup with no build step.
Prompt 2
How do I stack multiple lax.js presets on one element to make it slide in and fade in at the same time?
Prompt 3
I am using lax.js in a React component. How do I add and remove elements on component mount and unmount?
Prompt 4
How do I create a custom lax.js driver that animates an element based on mouse cursor X position instead of scroll?

Frequently asked questions

wtf is lax.js?

A tiny JavaScript library under 4KB that adds scroll-triggered animations, fade, slide, spin, inertia, to any web page with no dependencies, using simple class names or a driver-and-element API.

What language is lax.js written in?

Mainly JavaScript. The stack also includes JavaScript.

How hard is lax.js to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is lax.js for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.