Dioxus Motion 🚀
A lightweight, cross-platform animation library for Dioxus, designed to bring smooth, flexible animations to your Rust web, desktop, and mobile applications.
🎯 Live Examples
Visit our Example Website to see these animations in action:
- 🌸 Flower Animation
- 📝 Cube Floating Animation
- 🔄 Morphing Shapes
- 📝 Typewriter Effect
- ⚡ Path Animations
Quick Example
use *;
✨ Features
- Cross-Platform Support: Works on web, desktop, and mobile
- Flexible Animation Configuration
- Custom Easing Functions
- Modular Feature Setup
- Simple, Intuitive API
🛠 Installation
Add to your Cargo.toml:
[]
= { = "0.2.0", = true, = false }
[]
= ["web"]
= ["dioxus/web", "dioxus-motion/web"]
= ["dioxus/desktop", "dioxus-motion/desktop"]
= ["dioxus/mobile", "dioxus-motion/desktop"]
🌐 Platform Support
Choose the right feature for your platform:
web: For web applications using WASMdesktop: For desktop and mobile applicationsdefault: Web support (if no feature specified)
🚀 Quick Start
🔄 Migration Guide (v0.2.0)
Breaking Changes
- Combined
use_value_animationanduse_transform_animationintouse_motion - New animation configuration API
- Updated spring physics parameters
- Changed transform property names
New Animation API
use *;
// Before (v0.1.x)
let mut motion = use_value_animation;
// After (v0.2.x)
let mut value = use_motion;
value.animate_to;
// Before (v0.1.x)
let mut transform = use_transform_animation;
// After (v0.2.x)
let mut transform = use_motion;
transform.animate_to;
If you were using transform.get_style(), that function is removed to make the library more generic so i recommend building something like
let transform = use_motion;
let transform_style = use_memo;
// and using the memo in the component
rsx!
🆕 New Features
Loop Modes
.with_loop
.with_loop
Animation Delays
.with_delay
On Complete
.with_on_complete
🎓 Advanced Guide: Extending Animations
Implementing the Animatable Trait
The Animatable trait allows you to animate any custom type.
Defination of Animatable Trait
Here's how to implement it:
Custom Position Type
Best Practices
- Zero State: Implement zero() as your type's neutral state
- Epsilon: Choose a small value (~0.001) for animation completion checks
- Magnitude: Return the square root of sum of squares for vector types
- Scale: Multiply all components by the factor
- Add/Sub: Implement component-wise addition/subtraction
- Interpolate: Use linear interpolation for smooth transitions
Common Patterns
Circular Values (e.g., angles)
Normalized Values (e.g., colors)
🌈 Supported Easing Functions
Leverages the easer crate, supporting:
- Linear
- Quadratic
- Cubic
- Quartic
- And more!
🤝 Contributing
- Fork the repository
- Create your feature branch
- Commit changes
- Push to the branch
- Create a Pull Request
📄 License
MIT License
🐞 Reporting Issues
Please report issues on the GitHub repository with:
- Detailed description
- Minimal reproducible example
- Platform and feature configuration used
🌟 Motivation
Bringing elegant, performant motion animations to Rust's web and desktop ecosystems with minimal complexity.