# jakiestfu/snap.js

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/jakiestfu-snap-js).**

5,952 stars · 646 forks · JavaScript

## Links

- GitHub: https://github.com/jakiestfu/Snap.js
- Homepage: http://jakiestfu.github.io/Snap.js/
- awesome-repositories: https://awesome-repositories.com/repository/jakiestfu-snap-js.md

## Description

Snap.js is a JavaScript library for building draggable side navigation panels on touch devices. It enables slide-in menus from the left or right screen edge, driven by a gesture-based state machine that interprets drag and flick gestures to open and close the panel.

The library distinguishes horizontal menu drags from vertical scrolling by analyzing the initial touch movement angle, and locks menu movement to a single axis to prevent interference. It uses hardware-accelerated CSS transforms for smooth animations and provides configurable snap thresholds that determine whether a drag should open or close the menu based on release distance. Event listeners are attached to the document body, with support for excluding specific child elements from triggering the menu.

Snap.js exposes a programmatic toggle API for opening or closing menus without gesture input, along with lifecycle callbacks that fire at drag start, open, close, and animation completion. It also supports custom CSS class application, drag direction restriction, and real-time querying of the menu's position and open percentage.

## Tags

### User Interface & Experience

- [Side Menu Frameworks](https://awesome-repositories.com/f/user-interface-experience/side-menu-frameworks.md) — Opens a navigation panel from the screen edge using drag and flick gestures for mobile interaction. ([source](http://jakiestfu.github.io/Snap.js/))
- [CSS Transform Animations](https://awesome-repositories.com/f/user-interface-experience/component-utilities/animation-engines/css-transform-animations.md) — Animates menu sliding using hardware-accelerated CSS transforms for smooth mobile performance.
- [Side Menu Visibility Toggles](https://awesome-repositories.com/f/user-interface-experience/context-menu-customizations/conditional-menu-items/menu-visibility-state-machines/side-menu-visibility-toggles.md) — Switches the side menu between open and closed states using a programmatic call or a gesture. ([source](http://jakiestfu.github.io/Snap.js/))
- [Snap Thresholds](https://awesome-repositories.com/f/user-interface-experience/coordinate-based-positioning/gesture-thresholding/snap-thresholds.md) — Uses configurable pixel thresholds to decide whether a drag should snap the menu open or closed.
- [Draggable Panels](https://awesome-repositories.com/f/user-interface-experience/draggable-panels.md) — Builds user interface panels that can be dragged open or closed with customizable thresholds and directional restrictions.
- [Drag Thresholds](https://awesome-repositories.com/f/user-interface-experience/form-and-input-management/interaction-and-event-handling/interaction-logic-hooks/interaction-controls/drag-thresholds.md) — Configures the minimum drag distance required to trigger the menu to snap open or closed. ([source](http://jakiestfu.github.io/Snap.js/))
- [Draggable Axis Constraints](https://awesome-repositories.com/f/user-interface-experience/form-and-input-management/interaction-modifiers/draggable-axis-constraints.md) — Locks menu movement to the horizontal axis, preventing vertical interference during drags.
- [Programmatic Menu Toggles](https://awesome-repositories.com/f/user-interface-experience/navigation-animations/menu-toggle-animations/programmatic-menu-toggles.md) — Opens or closes a specified side menu programmatically with custom buttons or triggers. ([source](https://cdn.jsdelivr.net/gh/jakiestfu/snap.js@develop/README.md))
- [Slide-Out Panels](https://awesome-repositories.com/f/user-interface-experience/slide-out-panels.md) — Lets users slide a navigation panel into view by dragging the main content area on touch devices.
- [Touch Gesture Detection](https://awesome-repositories.com/f/user-interface-experience/touch-gesture-detection.md) — Detects and interprets touch drags, flicks, and angles to determine user intent for opening or closing interface elements.
- [Touch Angle Disambiguation](https://awesome-repositories.com/f/user-interface-experience/touch-gesture-libraries/multi-touch-gesture-systems/touch-based-viewport-scrolling/touch-angle-disambiguation.md) — Determines user intent by calculating the initial touch movement angle to distinguish horizontal menu drags from vertical scrolls.
- [Menu Lifecycle Callbacks](https://awesome-repositories.com/f/user-interface-experience/context-menu-customizations/conditional-menu-items/menu-interaction-utilities/suggestion-menu-control/completion-menu-triggers/menu-lifecycle-callbacks.md) — Fires callbacks when dragging starts, the menu opens, or an animation completes. ([source](https://cdn.jsdelivr.net/gh/jakiestfu/snap.js@develop/README.md))
- [Drag Direction Restrictions](https://awesome-repositories.com/f/user-interface-experience/form-and-input-management/interaction-and-event-handling/drag-operation-controls/drag-handles/drag-direction-restrictions.md) — Limits menu dragging to one specific side or disables it entirely to control how the panel is revealed. ([source](http://jakiestfu.github.io/Snap.js/))
- [Mobile Animation Libraries](https://awesome-repositories.com/f/user-interface-experience/list-transition-animations/mobile-animation-libraries.md) — Adds smooth slide animations and snap behaviors to mobile interface elements triggered by touch gestures.
- [Expandable Menu Contents](https://awesome-repositories.com/f/user-interface-experience/side-menu-frameworks/expandable-menu-contents.md) — Displays additional content like nested navigation links or extra options inside the side panel. ([source](http://jakiestfu.github.io/Snap.js/))
- [Lifecycle Callbacks](https://awesome-repositories.com/f/user-interface-experience/side-menu-frameworks/lifecycle-callbacks.md) — Manages side menu states and events including open, close, drag start, and animation completion with callback hooks.

### Part of an Awesome List

- [Gesture Menus](https://awesome-repositories.com/f/awesome-lists/devtools/touch-and-gestures/gesture-menus.md) — Detects drag and flick gestures to open and close mobile navigation panels with configurable sensitivity.

### Development Tools & Productivity

- [Gesture State Machines](https://awesome-repositories.com/f/development-tools-productivity/change-tracking/state-tracking-utilities/frontend-state-tracking/gesture-state-machines.md) — Manages menu open/close states by tracking drag gestures and snapping to predefined positions.
- [Menu State Toggles](https://awesome-repositories.com/f/development-tools-productivity/change-tracking/state-tracking-utilities/frontend-state-tracking/gesture-state-machines/programmatic-gesture-state-controllers/menu-state-toggles.md) — Exposes open/close methods that bypass gesture detection for external controls.

### Operating Systems & Systems Programming

- [Touch Drag Intent Detections](https://awesome-repositories.com/f/operating-systems-systems-programming/intent-monitoring/hover-intent-detection/touch-drag-intent-detections.md) — Determines whether a touch drag should open the side menu or scroll the page. ([source](https://cdn.jsdelivr.net/gh/jakiestfu/snap.js@develop/README.md))

### Software Engineering & Architecture

- [Drag Exclusion Elements](https://awesome-repositories.com/f/software-engineering-architecture/api-documentation-generators/element-exclusion/drag-exclusion-elements.md) — Prevents the menu from opening when users interact with designated child elements like sliders or forms. ([source](https://cdn.jsdelivr.net/gh/jakiestfu/snap.js@develop/README.md))
- [Lifecycle Callbacks](https://awesome-repositories.com/f/software-engineering-architecture/event-driven-callbacks/lifecycle-callbacks.md) — Fires user-defined callbacks at drag start, open, close, and animation completion.
