Overview
Svelte-waypoint is a powerful and efficient library designed for lazy loading images and components within Svelte and Sapper applications. This tool helps optimize your web app’s performance by delaying the loading of elements until they are necessary, which is especially useful for maintaining fast loading times and improving user experience. With various customizable options, it makes it easy to integrate into your existing projects and enhances functionality with minimal effort.
Features
- Throttle Control: Adjusts the interval in milliseconds for listener function execution, with a default setting of 250ms, allowing for smooth performance management.
- Offset Customization: Set a distance in pixels to determine when elements are marked as visible, enhancing precision for lazy loading.
- Class Propagation: Although deprecated, it allows passing classes to the waypoint’s wrapper to maintain styling consistency across components.
- Dynamic Styling: Supports style properties for the waypoint wrapper, enabling easy customization to fit your design needs.
- Single Load Option: Control element behavior with a ‘once’ option; set to false to have components reappear every time they leave the viewport.
- Threshold Setting: Define how much of the element must be visible before triggering a callback, with a scale from 0 to 1, offering flexibility in lazy loading.
- Disable Feature: Quickly disable lazy loading functionality when needed, with a default setting of false for instant activation.
- Enter and Leave Callbacks: Utilize events to execute functions when components enter or leave the viewport, allowing for dynamic interactions and animations.