1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//! Core types for layout animations
use serde::{Deserialize, Serialize};
/// Layout animation configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LayoutAnimationConfig {
/// Animation duration in milliseconds
pub duration: f64,
/// Easing function for the animation
pub easing: String,
/// Animation delay in milliseconds
pub delay: f64,
/// Stagger delay between elements in milliseconds
pub stagger: f64,
/// Whether to use FLIP algorithm
pub use_flip: bool,
/// Shared element transition settings
pub shared_elements: SharedElementConfig,
/// Performance settings
pub performance: PerformanceConfig,
/// Layout preset to use
pub preset: Option<String>,
}
/// Shared element configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SharedElementConfig {
/// Whether to enable shared element transitions
pub enabled: bool,
/// Transition duration for shared elements
pub duration: f64,
/// Easing for shared element transitions
pub easing: String,
/// Whether to maintain aspect ratio
pub maintain_aspect_ratio: bool,
/// Z-index management strategy
pub z_index_strategy: ZIndexStrategy,
}
/// Performance configuration for layout animations
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PerformanceConfig {
/// Whether to use hardware acceleration
pub hardware_acceleration: bool,
/// Frame budget for layout calculations
pub frame_budget_ms: f64,
/// Whether to batch layout updates
pub batch_updates: bool,
/// Memory pool size for layout objects
pub memory_pool_size: usize,
}
/// Z-index management strategies
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ZIndexStrategy {
/// Maintain original z-index
Maintain,
/// Elevate during transition
Elevate,
/// Use custom z-index
Custom(i32),
}
impl Default for LayoutAnimationConfig {
fn default() -> Self {
Self {
duration: 300.0,
easing: "ease-in-out".to_string(),
delay: 0.0,
stagger: 0.0,
use_flip: true,
shared_elements: SharedElementConfig::default(),
performance: PerformanceConfig::default(),
preset: None,
}
}
}
impl Default for SharedElementConfig {
fn default() -> Self {
Self {
enabled: true,
duration: 400.0,
easing: "cubic-bezier(0.4, 0.0, 0.2, 1)".to_string(),
maintain_aspect_ratio: true,
z_index_strategy: ZIndexStrategy::Elevate,
}
}
}
impl Default for PerformanceConfig {
fn default() -> Self {
Self {
hardware_acceleration: true,
frame_budget_ms: 16.67, // 60 FPS
batch_updates: true,
memory_pool_size: 100,
}
}
}
impl Default for ZIndexStrategy {
fn default() -> Self {
Self::Maintain
}
}