Why LISN?
LISN makes it super simple and easy to implement any kind of scroll, view, size, layout or user gesture triggered actions or animations with minimal boilerplate, and even if you wish, with zero JavaScript, using the HTML-only mode. It also comes with many customizable widgets.
- 100% vanilla TypeScript.
- No layout thrashing.
- Optimal performance.
- Server-side rendering.
- Flexible and customizable.
- Easy and simple to use.
- No dependencies.
- HTML-only mode.
Do anything with the watchers/triggers, actions and widgets:
- Scroll watcher
- Gesture watcher
- View watcher
- Size watcher
- Layout watcher
- DOM watcher
- Pointer watcher
- Collapsible
- Floating popup/tooltip
- Modal
- Offcanvas menu
- Pager (carousel/slider/tabs)
- Flex same-height
- Scrollbars (native scrolling)
- Sortable
- Auto-hide/remove matching elements
- Scroll-to-top button
- Page loader
- Coming soon: Native smooth scrolling and scroll-based transforms
Getting started.
npm install lisn.js
# OR
yarn add lisn.js
Then import the components and any required CSS in your project:// For example, import the pager widget
import { Pager } from "lisn.js";
import "lisn.js/pager.css"
npm install @lisn.js/react
# OR
yarn add @lisn.js/react
Then import the components and any required CSS in your project:// For example, import the pager widget
import { PagerComponent, PagerPageComponent } from "@lisn.js/react";
import "lisn.js/pager.css"
lisn.min.js
with your bundle of choice.<script
src="https://cdn.jsdelivr.net/npm/@lisn.js/bundles@1.2.1/lisn.min.js"
charset="utf-8"
></script>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@lisn.js/bundles@1.2.1/styles/lisn.css"
type="text/css"
media="screen"
title="no title"
charset="utf-8"
/>
<!-- or download and embed it manually -->
Then use the LISN
global variable as your entry point.// For example, using the scroll watcher
LISN.watchers.ScrollWatcher.onScroll(
() => {/* do something cool */},
{/* config... */}
);
or alternatively, just start using the triggers and widgets in HTML-only mode:<div data-lisn-modal
data-lisn-on-view="@open +target=top: 50% +rootMargin=-48%,0px +once"
>
<p>
Here's a modal popping up to tell you you've reached the middle of the page!
</p>
<p class="footnote">
P.S. Don't do that, popups are annoying.
</p>
</div>
Next steps: basic concepts and the API reference »
Choose your bundle.
There are pre-build bundles available as CDN assets. You can download them directly from the repository or install the @lisn.js/bundles node package.
Default: lisn.min.js
Includes everything: watchers, triggers, actions, widgets and their CSS (dynamically injected).
Slim: lisn.slim.min.js
Includes watchers, triggers and actions but not widgets or widget-specific actions.
Essentials: lisn.essentials.min.js
Includes just the watchers.
Debug/dev (not minified): lisn.debug.js
You likely won't be using it but it's there. Includes everything the default bundle does plus utility functions and logging functionality including remote logging via socket.io for easier testing on mobile.
Browser support.
Official support is for:
- Chrome >= 64
- Edge >= 79
- Firefox >= 69
- Safari >= 13.1
- iOS >= 13.4
If you require older browser support (like IE), you'll need to transpile from source and include polyfills for ResizeObserver
, IntersectionObserver
and possibly other features.
Future plans.
- SmoothScroll widget (coming in next version).
- Momentum based Pager transition.
- Realtime drag to reveal for Pager (slider mode).
- Sortable to support a child element of each sortable item to function as the drag handle.
- Wrappers for more frameworks.
- You tell me :)