$ show hammerjs/hammer.js
Hammer.js is a JavaScript library for detecting touch gestures in web applications. It provides a modular architecture with a Manager class that coordinates input handling (touch, mouse, pointer events) and gesture recognition (tap, double tap, press, pan, swipe, pinch, rotate). The library normalizes different input types into a consistent gesture recognition system, manages gesture lifecycle states, and handles touch-action CSS property polyfilling. It features an event-driven architecture where recognizers emit events when gestures are detected, which are forwarded to registered listeners. The library has no runtime dependencies, relying solely on standard web APIs.
The LLM identified 3 files worth highlighting for reuse:
Manages touch-action CSS property by computing appropriate values based on active recognizers and providing a polyfill for browsers without native support. Demonstrates smart dependency management between gesture recognition and browser behavior prevention through intelligent computation of touch-action values and fallback handling.
Wrapper around setTimeout that ensures proper context binding, preventing common mistakes with 'this' in timeout callbacks. Essential for managing timeouts in object-oriented JavaScript without memory leaks, showing good practice for asynchronous operations in class-based code.
Utility that allows configuration options to accept either static values or functions that return values. Enables dynamic configuration while maintaining a simple API pattern used throughout the library for options like enable, demonstrating clean API design for flexible configuration.