How desandro/draggabilly works
Main Components
• Core Library Module: Represent the key file (draggabilly.js), which implements the core drag-and-drop logic, event binding, options management, and public API. This is the heart of the system.
• Distribution Bundle: Include the “dist” folder, which holds the packaged and minified versions of the library for consumption (e.g., draggabilly.pkgd.js).
• Build Tools & Scripts: Show the “bin” directory with its bespoke scripts (e.g., build-dist.js for building the distribution, lint-json.js, version.js) which are used to automate tasks such as building, linting, and versioning.
• Sandbox / Examples: The “sandbox” folder contains example usage (both for require.js and vanilla HTML examples) that demonstrate how to integrate Draggabilly. This illustrates how consumers will test and interact with the library in real-world scenarios.
• Testing Suite: Illustrate the “test” directory that holds unit tests (with folders and files for basic functionality and jQuery-specific tests as well as front-end demos via HTML).
Relationships and Interactions
• Consumers (Developers/Applications): Show how external applications or webpage consumers interact with the library. They download the built bundles via CDNs, package managers, or directly from the “dist” folder.
• API Consumers: Indicate two main integrations:
• Vanilla JS consumers using the new Draggabilly(…) constructor.
• jQuery Plugin consumers via the jquery-bridget integration.
• Build Pipeline: Represent the relationship between the source module, build scripts (in the “bin” folder), and the resulting distribution bundle (in the “dist” folder). This illustrates the compilation and packaging process.
• Testing: Link the core module and the sandbox demos to the test suite. This shows how the functionality is verified and how changes can be validated via unit tests.
• Event & Method Handlers: Within the library, highlight the use of events (e.g., dragStart, dragMove, dragEnd, pointer events) for interactive behavior and note how these events are exposed as the public API.
Architectural Patterns and Design Principles
• Modular Design: The library is built as a modular component that can be used either as a standalone vanilla JS module or extended for jQuery use. Emphasize the separation between core functionality and integration/adaptation layers.
• Testing & Sandbox Guidance: Highlight the importance of isolated test cases and real-world examples found in the “sandbox” directory.
• Loose Coupling with External Dependencies: Even though the library supports jQuery, its core remains independent and can be integrated with various frameworks via adapters like jquery-bridget.