Background
Custom Swipe is a framework-agnostic, headless swipe library engineered to provide only the core computational swipe mechanics without enforcing any UI presentation styles.
It is decoupled from specific frontend frameworks like React, Vue, or Svelte, and was developed with the explicit goals of lightweight footprint and predictable runtime behavior even in low-end device constraints.
Problem Definition
Existing major swipe libraries suffered from several structural constraints:
- Inflated bundle sizes driven by feature creep and over-engineering.
- Design system style collisions caused by opinionated, built-in library styles.
- Heavy architectural dependency on framework-specific state-management lifecycles.
- High barriers to entry for customization, requiring developers to deeply reverse-engineer internal implementations.
In particular, there was a major lack of viable options for developers who "solely need the mathematical swipe gestures but want absolute, fine-grained control over the presentation UI."
Resolution Strategy
1. Headless Architecture
By entirely stripping away visual UI rendering layers, the core was engineered to expose exclusively the underlying coordinate calculations, touch/pointer event handling, and internal state transition rules.
This enables frictionless integration with project-specific internal design systems without being bottlenecked by structural markup or styling constraints.
2. DOM-Centric Uncontrolled Pattern
To guarantee absolute freedom from framework runtime state overhead (such as React's re-rendering cycles), the core computation loop was written natively using Vanilla DOM APIs.
- Eliminates redundant, expensive framework-level re-renders.
- Secures deterministic, highly predictable timing windows for animations and raw gesture handlings.
- Assures uniform, identical behavior profiles across completely different framework consumers.
3. Core + Wrapper Architecture (Monorepo)
Adopted a multi-package architecture hosted in a monorepo, maintaining a singular source of truth for the core mechanics while exposing tailored ecosystem wrappers.
custom-swipe(The Core Engine)react-custom-swipevue-custom-swipesvelte-custom-swipe
This strategy facilitates comprehensive multi-framework support without introducing redundant code duplication or maintenance fragmentation.
Key Features
- Swipe
- Infinite Swipe (Scroll Loops)
- Carousel / Slider Mechanics
- Headless Hook-Based Programmatic Control
Technical Stack & Rationale
-
TypeScript
→ Chosen to explicitly model complex touch gesture events, options interfaces, and strict type schemas. -
Vanilla DOM API
→ Selected to unlock low-level performance tuning, sub-millisecond gesture accuracy, and pure framework independence. -
Monorepo Architecture
→ Utilized to enforce structural consistency across downstream wrapper layers and optimize package maintenance cycles.
Results & Impact
- Achieved drastic minimization of client-side bundle size footprints.
- Delivered an identical, high-fidelity swipe interaction model across diverse runtime environments.
- Solidified a highly design-system-friendly Headless paradigm.
At its core, Custom Swipe was driven by a definitive engineering philosophy: "Leverage the power of a library, but never let the library dictate your architecture."