### Install svelte-motion Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/README.md Install the svelte-motion library using npm. This is the first step to using its animation capabilities in your Svelte project. ```bash npm install svelte-motion ``` -------------------------------- ### Direct Import Example Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/index.js.md Demonstrates importing multiple core utilities directly from the package root for convenience. ```javascript import { Motion, animate, useMotionValue } from 'svelte-motion'; ``` -------------------------------- ### Install Svelte Motion Source: https://github.com/michael-obele/svelte-motion/blob/master/README.md Install the svelte-motion package using npm. This is a development dependency. ```bash npm install --save-dev svelte-motion ``` -------------------------------- ### Initialize and Use PanSession Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/gestures.md Manages pointer tracking for drag and pan gestures. Use this to define callbacks for session start, pan start, move, and end events. ```js import { PanSession } from 'svelte-motion/gestures/PanSession'; // Create a new pan session const panSession = new PanSession(event, { onSessionStart: (event) => { console.log('Session started'); }, onStart: (event, info) => { console.log('Pan started', info.point); }, onMove: (event, info) => { console.log('Panning', info.delta.x, info.delta.y); }, onEnd: (event, info) => { console.log('Pan ended', info.velocity); } }, { transformPagePoint: (point) => point }); // End the session panSession.end(); ``` -------------------------------- ### Initialize and Use DragControls Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/gestures.md Provides programmatic control over drag gestures. Use this to start drag interactions and update constraints. ```js import { DragControls } from 'svelte-motion/gestures/drag/use-drag-controls'; const dragControls = new DragControls(); // Start a drag interaction dragControls.start(event, { snapToCursor: true }); // Update constraints dragControls.updateConstraints(); ``` -------------------------------- ### UseGestures Component Example Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/gestures.md Combines all gesture functionality (pan, tap, hover, focus, drag) into a single component. Requires a Motion component and binds its visualElement. ```svelte
Drag, tap, hover or focus me
``` -------------------------------- ### Use Animation Control Hooks Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/index.js.md Import and use useAnimation and animationControls to imperatively control animations, such as starting and stopping them. ```javascript import { useAnimation, animationControls } from 'svelte-motion'; const controls = useAnimation(); // Start animation controls.start({ x: 100 }); ``` -------------------------------- ### Svelte Motion Component Usage Example Source: https://github.com/michael-obele/svelte-motion/blob/master/src/motion/utils/DOCUMENTATION.md Demonstrates how a Svelte Motion component might internally use the useMotionRef action to bind to a DOM element and forward an external ref. ```svelte ``` -------------------------------- ### UsePanGesture for Panning/Dragging Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/gestures.md Handles panning and dragging gestures. Provides callbacks for pan start, ongoing pan, and pan end. Requires a visualElement reference. ```svelte ``` -------------------------------- ### UseHoverGesture for Hover Interactions Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/gestures.md Manages hover gestures, providing callbacks for when the hover starts and ends, and supporting `whileHover` animations. Requires a visualElement reference. ```svelte ``` -------------------------------- ### Create Custom MotionValues with svelte-motion Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/extending.md This example shows how to create a custom MotionValue for handling color animations. It extends the base `motionValue` to include color-specific methods like `setHex` and `getHex`. Ensure `parseColor` and `rgbToHex` functions are implemented correctly. ```javascript // colorMotionValue.js import { motionValue } from 'svelte-motion/value'; export function colorMotionValue(initialColor) { const value = motionValue(parseColor(initialColor)); return { // Expose the underlying motionValue get: value.get, set: value.set, onChange: value.onChange, // Add color-specific functionality getHex: () => { const { r, g, b } = value.get(); return rgbToHex(r, g, b); }, getRgb: () => { return value.get(); }, setHex: (hex) => { value.set(parseColor(hex)); } }; } function parseColor(color) { // Implementation to parse different color formats return { r: 0, g: 0, b: 0 }; // Placeholder } function rgbToHex(r, g, b) { // Implementation to convert RGB to hex return "#000000"; // Placeholder } ``` -------------------------------- ### UseDragControls for Programmatic Dragging Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/gestures.md Enables programmatic control over drag gestures. Use the `dragControls` prop to initiate drags, for example, with `snapToCursor`. ```svelte
This element will be dragged
``` -------------------------------- ### Imperative UseAnimation API Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/animation.md Manually create and control animations using the `useAnimation` hook. Controls can be used to start animations with specified properties and transitions. ```javascript import { useAnimation } from 'svelte-motion/animation/use-animation'; const controls = useAnimation(); // Controls can be used to start animations controls.start({ x: 100, transition: { duration: 0.5 } }); ``` -------------------------------- ### Integrate svelte-motion with D3.js for Animated Charts Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/extending.md This example demonstrates how to use svelte-motion's `animate` function to smoothly transition data points in a D3.js-generated SVG chart. It requires D3.js for SVG manipulation and svelte-motion for animation. ```svelte ``` -------------------------------- ### Internal UseLayoutId Component Logic Source: https://github.com/michael-obele/svelte-motion/blob/master/src/motion/utils/DOCUMENTATION.md This conceptual example shows how UseLayoutId.svelte might be used internally within a motion component to resolve and pass down a hierarchical layoutId. ```svelte ``` -------------------------------- ### Import and Use Configuration Components Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/index.js.md Import and use MotionConfig to set default transitions for all nested motion components, and LazyMotion for code-splitting animation features. ```javascript import { MotionConfig, LazyMotion } from 'svelte-motion'; <-- All motion components inside will use this transition --> <-- Code-split animation features --> ``` -------------------------------- ### Access ScaleCorrectionContext in Svelte Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/context.md Get scale correction information for nested animations using getContext with ScaleCorrectionContext. ```svelte import { ScaleCorrectionContext } from 'svelte-motion/context/ScaleCorrectionProvider.svelte'; import { getContext } from 'svelte'; // Access scale correction information const scaleCorrection = getContext(ScaleCorrectionContext); ``` -------------------------------- ### Use Advanced Animation Utilities Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/index.js.md Import advanced utilities like transform, useSpring, useVelocity, and useViewportScroll for physics-based animations and scroll-linked effects. ```javascript import { transform, useSpring, useVelocity, useViewportScroll } from 'svelte-motion'; // Spring physics const smoothX = useSpring(rawX); // Scroll values const { scrollYProgress } = useViewportScroll(); ``` -------------------------------- ### Access PresenceContext in Svelte Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/context.md Get presence information for managing component presence and exit animations by using getContext with PresenceContext. ```svelte import { PresenceContext } from 'svelte-motion/context/PresenceContext'; import { getContext } from 'svelte'; // Get presence information const presence = getContext(PresenceContext); ``` -------------------------------- ### Basic Motion Animation Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/README.md Demonstrates a basic animation where an element moves 100 pixels to the right over 2 seconds. Import the Motion component and use the 'animate' and 'transition' props. ```svelte
I will animate 100px to the right
``` -------------------------------- ### Use Gesture Hooks Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/index.js.md Import gesture hooks like useDragControls, UseGestures, UsePanGesture, and UseTapGesture for handling user interactions. ```javascript import { useDragControls, UseGestures, UsePanGesture, UseTapGesture } from 'svelte-motion'; // Create drag controls const dragControls = useDragControls(); dragControls.start(event); ``` -------------------------------- ### UseAnimation Component Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/animation.md The UseAnimation component creates AnimationControls, which can be used to manually start, stop, and sequence animations on one or more components. It can be used declaratively or imperatively. ```APIDOC ## UseAnimation Component ### Description A component that creates `AnimationControls`, which can be used to manually start, stop, and sequence animations on one or more components. ### Usage ```svelte
Animated content
``` ### Imperative API ```js import { useAnimation } from 'svelte-motion/animation/use-animation'; const controls = useAnimation(); controls.start({ x: 100, transition: { duration: 0.5 } }); ``` ``` -------------------------------- ### Use Visual Element Utilities Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/index.js.md Import visualElement, animateVisualElement, and isValidMotionProp for low-level manipulation and validation of motion elements. ```javascript import { visualElement, animateVisualElement, isValidMotionProp } from 'svelte-motion'; // Create a visual element const element = visualElement(config)(props); ``` -------------------------------- ### Import and Use Layout Animation Components Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/index.js.md Import and use AnimatePresence and AnimateSharedLayout for managing component entrance/exit animations and shared element transitions. ```javascript import { AnimatePresence, AnimateSharedLayout } from 'svelte-motion'; {#if visible} Content {/if} Content that animates between positions ``` -------------------------------- ### Get DOM Context in JavaScript Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/context.md Retrieve a context from the DOM hierarchy using the getDomContext utility. Specify the context name and the target DOM element. ```javascript import { getDomContext } from 'svelte-motion/context/DOMcontext'; // Get a specific context from a DOM element const motionContext = getDomContext('Motion', element); ``` -------------------------------- ### UseTapGesture for Tap/Click Interactions Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/gestures.md Handles tap and click gestures, allowing for associated animations like `whileTap`. Requires a visualElement reference. ```svelte ``` -------------------------------- ### Creating an HTML Visual Element Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/render.md Initializes an HTML visual element to manage animations and transformations for HTML elements. Options can be passed to configure hardware acceleration. ```javascript const visualElement = htmlVisualElement(options, { enableHardwareAcceleration: true }); ``` -------------------------------- ### animationControls Function Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/animation.md The animationControls function creates an object that allows you to control animations across multiple components. It provides methods to start, stop, and manage animations. ```APIDOC ## animationControls Function ### Description Creates an object to control animations across multiple components: ### Usage ```js import { animationControls } from 'svelte-motion/animation/animation-controls'; const controls = animationControls(); // Mount the controls when your component mounts onMount(controls.mount); // Start an animation on all linked components controls.start({ x: 100, transition: { duration: 0.5 } }); // Stop all animations controls.stop(); ``` ``` -------------------------------- ### Custom Drag Handler in Svelte Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/extending.md Implement a custom drag handler by extending the UseDrag component. This example shows how to track drag history and calculate velocity. ```svelte ``` -------------------------------- ### Configuring Default Transitions with MotionConfig Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/components.md Provide default animation settings, such as transition duration, to all descendant Motion components by wrapping them with MotionConfig. ```svelte
This will use the custom transition duration
``` -------------------------------- ### Import Context Providers Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/index.js.md Import context providers like MotionConfigContext, PresenceContext, and SharedLayoutContext to access context within custom components. ```javascript import { MotionConfigContext, PresenceContext, SharedLayoutContext } from 'svelte-motion'; // Access context in custom components const motionConfig = getContext(MotionConfigContext); ``` -------------------------------- ### Track Element Scroll with useElementScroll Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/value.md Use `useElementScroll` to get motion values that track the scroll position of a specific DOM element. Requires a Svelte reference to the element. ```js import { useElementScroll } from 'svelte-motion/value/scroll/use-element-scroll'; // With a Svelte reference let element; const { scrollX, scrollY, scrollXProgress, scrollYProgress } = useElementScroll({ current: element }); ``` -------------------------------- ### Integration with Svelte Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/value.md Demonstrates how motion values can be used with Svelte's reactive system. ```APIDOC ## Integration with Svelte ### Description Motion values implement the Svelte store interface, making them compatible with Svelte's reactive system. ### Usage ```svelte
Animated content
Animated content
``` ``` -------------------------------- ### Create and Control a MotionValue Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/value.md Instantiate a MotionValue to track state and velocity. Use `.set()` to animate to a new value and `.get()` to retrieve the current value. ```js import { motionValue } from 'svelte-motion/value'; const x = motionValue(0); x.set(100); // Animates to 100 x.get(); // Returns current value x.getVelocity(); // Returns current velocity ``` -------------------------------- ### Get Global Drag Lock Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/gestures.md Retrieves a lock for a specific drag direction to ensure only one drag operation occurs globally. The returned function should be called to release the lock. ```js import { getGlobalLock, isDragActive } from 'svelte-motion/gestures/drag/utils/lock'; // Get a lock for a drag direction const lock = getGlobalLock("x"); if (lock) { // We have the lock, can start dragging // Later, release the lock lock(); } ``` -------------------------------- ### Code Splitting with LazyMotion Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/extending.md Use LazyMotion to import animation features on demand, improving initial load times. Ensure the features import path is correct. ```svelte import('svelte-motion/features/dom')}>\n \n Content\n \n ``` -------------------------------- ### addDomEvent Function for DOM Event Listeners Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/events.md Manually attach a DOM event listener to an element and get a cleanup function. Remember to call the cleanup function to prevent memory leaks. ```javascript import { addDomEvent } from 'svelte-motion/events/use-dom-event'; const element = document.querySelector('.my-element'); const cleanup = addDomEvent(element, 'click', (event) => { console.log('Element clicked'); }); // Later, when you want to remove the listener cleanup(); ``` -------------------------------- ### AnimationControls Function for Multiple Components Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/animation.md Create an `AnimationControls` object using `animationControls` to manage animations across multiple components. Remember to mount the controls when your component mounts and use `start` or `stop` to control animations. ```javascript import { animationControls } from 'svelte-motion/animation/animation-controls'; const controls = animationControls(); // Mount the controls when your component mounts onMount(controls.mount); // Start an animation on all linked components controls.start({ x: 100, transition: { duration: 0.5 } }); // Stop all animations controls.stop(); ``` -------------------------------- ### Basic Usage with Motion Component Source: https://github.com/michael-obele/svelte-motion/blob/master/README.md Use the Motion component for standard HTML elements. Import Motion and apply it using the 'use:motion' directive. ```javascript import { Motion } from 'svelte-motion'
``` -------------------------------- ### Animate with Spring Physics using useSpring Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/value.md Apply spring physics to a motion value using `useSpring`. You can define stiffness and damping, or have it follow another motion value. ```js import { useSpring } from 'svelte-motion/value/use-spring'; // Spring from initial value 0 const x = useSpring(0, { stiffness: 300, damping: 20 }); // Or spring to follow another motion value const smoothX = useSpring(x, { stiffness: 100, damping: 30 }); ``` -------------------------------- ### Code-Splitting Animations with LazyMotion Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/components.md Reduce bundle size by code-splitting animation features using LazyMotion and the 'm' component import. Ensure the required features are passed to LazyMotion. ```svelte This will animate ``` -------------------------------- ### Browser Support Detection Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/events.md Provides utility functions to detect browser support for pointer, touch, and mouse events, allowing for graceful degradation and fallback strategies. ```APIDOC ## Browser Support Detection Utilities ### Description Utilities to detect browser support for different event types, enabling adaptive event handling strategies. ### Functions - **supportsPointerEvents()**: Returns `true` if pointer events are supported, `false` otherwise. - **supportsTouchEvents()**: Returns `true` if touch events are supported, `false` otherwise. - **supportsMouseEvents()**: Returns `true` if mouse events are supported, `false` otherwise. ### Usage ```js import { supportsPointerEvents, supportsTouchEvents, supportsMouseEvents } from 'svelte-motion/events/utils'; if (supportsPointerEvents()) { // Use pointer events } else if (supportsTouchEvents()) { // Fall back to touch events } else if (supportsMouseEvents()) { // Fall back to mouse events } ``` ``` -------------------------------- ### HTML Component Rendering with UseHTMLProps Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/render.md Processes props for HTML elements and generates appropriate style values for rendering. Use this to apply motion props to standard HTML elements. ```svelte
Content
``` -------------------------------- ### Apply Custom Bounce Transition Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/extending.md Apply a custom 'bounce' transition to a Motion component. Ensure the transition definition is imported correctly. ```svelte
Custom bounce animation
``` -------------------------------- ### Import and Use Motion Components Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/index.js.md Import and use Motion and MotionDiv components for animating elements. Motion can be used with any Svelte element via the `use:motion` action. ```javascript import { Motion, MotionDiv } from 'svelte-motion'; // Use Motion with any element
Animated content
// Or use MotionDiv for convenience Animated content ``` -------------------------------- ### Define Custom Spring and Tween Transitions Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/extending.md Define custom transition objects for 'spring' and 'tween' animations. These can be imported and used with the Motion component. ```javascript // myTransitions.js export const bounce = { type: "spring", stiffness: 300, damping: 10, restDelta: 0.5, restSpeed: 10 }; export const slowFade = { type: "tween", duration: 1.5, ease: [0.43, 0.13, 0.23, 0.96] }; ``` -------------------------------- ### UseFocusGesture for Focus Interactions Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/gestures.md Handles focus gestures, enabling visual feedback like `whileFocus` when the element gains or loses focus. Requires a visualElement reference. ```svelte ``` -------------------------------- ### Creating a Custom Motion Component Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/motion.md Use the createMotionComponent factory function to build custom motion components with specific configurations, features, and element types. ```javascript import { createMotionComponent } from 'svelte-motion/motion'; const MyMotionComponent = createMotionComponent({ preloadedFeatures, createVisualElement, Component: 'div' }); ``` -------------------------------- ### UsePointerEvent Component Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/events.md A specialized Svelte component for handling pointer events consistently across mouse, touch, and pen input devices. It simplifies cross-device event management and includes automatic cleanup. ```APIDOC ## UsePointerEvent Component ### Description A specialized component for handling pointer events consistently across mouse, touch, and pen input devices. It simplifies cross-device event management and automatically handles cleanup. ### Usage ```svelte
``` ### Props - **ref** (object) - Required - An object with a `current` property referencing the DOM element. - **eventName** (string) - Required - The name of the pointer event to listen for (e.g., 'pointerdown', 'pointermove'). - **handler** (function) - Required - The callback function to execute. Receives the raw event and an `info` object. - **options** (object) - Optional - Event listener options. ``` -------------------------------- ### Animate Presence with Motion Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/README.md Utilizes AnimatePresence and Motion components to animate elements entering and exiting the DOM. Use 'initial', 'animate', and 'exit' props for opacity transitions. Requires a conditional rendering block. ```svelte {#if isVisible}
I will animate in and out
{/if}
``` -------------------------------- ### Use Presence Utilities Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/index.js.md Import usePresence and useIsPresent to check if a component is currently rendered within an AnimatePresence component. ```javascript import { usePresence, useIsPresent } from 'svelte-motion'; // Check if component is present in AnimatePresence const isPresent = useIsPresent(); const [isPresent, safeToRemove] = usePresence(); ``` -------------------------------- ### UsePointerEvent Component for Pointer Events Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/events.md Handle pointer events (mouse, touch, pen) consistently. The handler receives the raw event and an 'info' object with standardized point data. Cleanup is automatic. ```svelte
``` -------------------------------- ### useMotionTemplate Hook Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/value.md Combines multiple motion values into a single string using a template literal. ```APIDOC ## useMotionTemplate ### Description Combine multiple motion values into a single string using a template literal. ### Usage ```js import { useMotionValue } from 'svelte-motion/value/use-motion-value'; import { useMotionTemplate } from 'svelte-motion/value/use-motion-template'; const x = useMotionValue(0); const y = useMotionValue(0); const boxShadow = useMotionTemplate`${x}px ${y}px 10px rgba(0,0,0,0.3)`; ``` ``` -------------------------------- ### Use the Custom Animated Button Component Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/extending.md Integrate the custom `MotionButton` component into your application. Configure its animation properties and event handlers. ```svelte Animated Button ``` -------------------------------- ### useVelocity Hook Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/value.md Creates a motion value that tracks the velocity of another motion value. ```APIDOC ## useVelocity ### Description Create a motion value that tracks the velocity of another motion value. ### Usage ```js import { useMotionValue } from 'svelte-motion/value/use-motion-value'; import { useVelocity } from 'svelte-motion/value/use-velocity'; const x = useMotionValue(0); const xVelocity = useVelocity(x); ``` ``` -------------------------------- ### Visual Element Flow Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/implementation.md Illustrates the data flow from a DOM element through the Visual Element abstraction to Motion Values and animation. ```text DOM Element → Visual Element → Motion Values → Animation ``` -------------------------------- ### Basic Animation with Motion.svelte Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/motion.md Use the Motion component to animate a div. It manages visual elements and animation states, providing reactive motion props. ```svelte
Animated content
``` -------------------------------- ### useMotionValue Hook Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/value.md A hook to create a motion value with an initial state. ```APIDOC ## useMotionValue ### Description Create a motion value with an initial state. ### Usage ```js import { useMotionValue } from 'svelte-motion/value/use-motion-value'; const opacity = useMotionValue(1); ``` ``` -------------------------------- ### Cycle Through Values with useCycle Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/utils.md A hook for creating a cycling state that rotates through a predefined list of values. Useful for animations that loop through states. ```javascript import { useCycle } from 'svelte-motion/utils/use-cycle'; // Create a cycling state that rotates through 0, 90, 180, 270 degrees const rotation = useCycle(0, 90, 180, 270); ``` -------------------------------- ### Combine MotionValues with useMotionTemplate Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/value.md Use `useMotionTemplate` to create a string output by interpolating multiple motion values within a template literal. This is useful for CSS properties like `boxShadow`. ```js import { useMotionValue } from 'svelte-motion/value/use-motion-value'; import { useMotionTemplate } from 'svelte-motion/value/use-motion-template'; const x = useMotionValue(0); const y = useMotionValue(0); const boxShadow = useMotionTemplate`${x}px ${y}px 10px rgba(0,0,0,0.3)`; ``` -------------------------------- ### SVG Component Rendering with UseSVGProps Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/render.md Processes props for SVG elements and generates appropriate attribute values for rendering. Use this for applying motion props to SVG elements. ```svelte ``` -------------------------------- ### LazyMotion Component Usage Source: https://github.com/michael-obele/svelte-motion/blob/master/src/components/LazyMotion/DOCUMENTATION.md Wrap parts of your application with LazyMotion and provide a dynamic import function for features like domMax. This ensures animation and gesture code is only loaded when the component mounts. ```svelte ``` -------------------------------- ### Track Viewport Scroll with useViewportScroll Source: https://github.com/michael-obele/svelte-motion/blob/master/docs/value.md Obtain motion values that automatically update with the viewport's scroll position using `useViewportScroll`. This provides `scrollX`, `scrollY`, `scrollXProgress`, and `scrollYProgress`. ```js import { useViewportScroll } from 'svelte-motion/value/scroll/use-viewport-scroll'; const { scrollX, scrollY, scrollXProgress, scrollYProgress } = useViewportScroll(); ```