
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
CuaJs is a lightweight, powerful JavaScript library that transforms traditional vertical scrolling into a smooth, intuitive horizontal experience. With Lenis smooth scrolling deeply integrated for fluid animations, it delivers buttery-smooth transitions and scroll-based effects. Named after the Vietnamese word for crab, CuaJs brings a sideways 'crab walk' to web navigation. See Demo.
CuaJs offers web developers a unique tool to create engaging, horizontally-scrolling websites without sacrificing usability or accessibility. Whether you're building a portfolio, product showcase, or innovative web experience, CuaJs provides the framework for smooth, intuitive sideways navigation.
CuaJs can run independently, but integrating Lenis unlocks enhanced features like butter-smooth animations, optimized scroll transitions, and improved cross-browser scrolling behavior.
Using a package manager:
npm i @studio-freight/lenis
npm i cuajs
import Lenis from '@studio-freight/lenis'
import "cuajs";
Using CDN:
<!-- Lenis smooth scroll -->
<script src="https://cdn.jsdelivr.net/gh/studio-freight/lenis@1/bundled/lenis.min.js"></script>
<!-- CuaJs -->
<script src="https://cdn.jsdelivr.net/gh/phucbm/cuajs@0.0.5/dist/cua.min.js"></script>
<!-- Cua Animate (optional, for animation only) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/phucbm/cuajs@0.0.5/dist/cua-animate.css">
<!-- [data-cua] must be defined -->
<div data-cua>
<!-- Each child of wrapper must have [data-cua-section] -->
<section data-cua-section></section>
<section data-cua-section></section>
</div>
Setting options via HTML
<div data-cua='{"verticalBreakpoint":"1024"}'>
</div>
const instance = CuaJs.init({
wrapper: document.querySelector('.wrapper')
});
After init(), you can either use instance which is returned from the init function, or CuaInstance to access methods.
| Attribute | Type | Default | Description |
|---|---|---|---|
wrapper | DOM element | undefined | Required. Wrapper element. |
smoothScroll | boolean | true | Enable smooth scroll |
verticalBreakpoint | number | 1024 | Switch to vertical layout mode when window.innerWidth <= 1024 |
smoothVerticalScroll | boolean | true | Enable smooth scroll for vertical layout mode |
keyScrollDistance | number | 200 | Distance to scroll on each key press (px) |
keyScroll | boolean | true | Enable navigate by a arrow key |
onScrollableContent | function | undefined | Callback on each scrollable content |
once | boolean | true | Scroll Observer: Only run "enter" callback once. |
rootMargin | string | 0px | Scroll Observer: Margin around the viewport for intersection calculations |
threshold | number | 0.1 | Scroll Observer: Percentage of element visibility to trigger intersection |
draggable | boolean | false | Enable drag to scroll |
scrollSnap | boolean | false | Snap to the nearest section |
| Name | Usage | Description |
|---|---|---|
assignScrollObserver | CuaInstance.assignScrollObserver({element, options, enter,leave,once}) | Assign a scroll observer to a specific element |
on | CuaInstance.on() | Assign events |
Assign onScroll event:
CuaInstance.on('onScroll', (data) => {
console.log(data.axis, data.progress);
// more info
console.log(data);
});
CuaInstance.on('onSectionChange', ({index, instance, section}) => {
console.log(`Active index`, index);
});
Scroll Observer is a functionality that utilizes Intersection Observer to monitor a specific element and trigger a callback function when that element enters or exits the viewport. This feature is particularly useful for creating animations that appear as elements come into view.
By default, Scroll Observer adds the class "cua-intersection" to an element when it enters the viewport and removes this class when the element leaves. To activate this default behavior, simply add the attribute data-cua-observe to the desired element.
<div data-cua>
<section data-cua-section>
<div data-cua-observe>
Item with scroll observer
</div>
</section>
</div>
For more customized control, you can define a custom observer using the assignScrollObserver function. Here's an example of how to implement this:
CuaInstance.assignScrollObserver({
element: document.querySelector('.my-element'),
options: {
rootMargin: '0px',
threshold: 0.5,
once: true
},
enter: (entry) => {
console.log('Element entered viewport:', entry.target);
// Add your enter logic here
},
leave: (entry) => {
console.log('Element left viewport:', entry.target);
// Add your leave logic here
}
});
When Lenis is enabled, CuaJs exposes scroll velocity through the CSS variable --scroll-velocity on the wrapper
element.
This enables powerful scroll-based animations like parallax effects, scroll-triggered animations, and more.
Add animations using data-cua-animate with values like "mask", "tilt", or "fade-in".
Create custom scroll animations using CSS variables --scroll-velocity, --scroll-progress, and --scroll-direction. Check demos at https://cuajs.netlify.app.
# Install
npm i
# Run dev server
npm run dev
# Build dev site
npm run build
# Generate production files
npm run prod
Copyright (c) 2024 PHUCBM
FAQs
Crab-walk through your website with CuaJs.
We found that cuajs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.