Skip to content

Commit a9f56f6

Browse files
author
mayintao3
committed
feat: 添加animation fill mode
1 parent 30e7792 commit a9f56f6

File tree

3 files changed

+253
-235
lines changed

3 files changed

+253
-235
lines changed

src/style_propetries/animation.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub struct Animation {
2222
pub animation_duration: Option<f32>,
2323
pub animation_delay: Option<f32>,
2424
pub animation_iteration: Option<f32>,
25+
pub animation_fill_mode: Option<style_property_enum::ArkUI_AnimationFillMode>,
2526
pub animation_timeing_function: Option<AnimationTimingFunction>
2627
}
2728

@@ -32,6 +33,7 @@ impl From<(String, &Property<'_>, Option<Rc<RefCell<HashMap<String, Vec<KeyFrame
3233
let mut animation_duration = None; // 0.0
3334
let mut animation_delay = None; // 0.0
3435
let mut animation_iteration = None; // 1.0
36+
let mut animation_fill_mode = None;
3537
let mut animation_timeing_function: Option<AnimationTimingFunction> = None; // EasingFunction::Ease
3638

3739
match value.1 {
@@ -59,6 +61,13 @@ impl From<(String, &Property<'_>, Option<Rc<RefCell<HashMap<String, Vec<KeyFrame
5961
animation::AnimationIterationCount::Infinite => -1.0,
6062
});
6163

64+
animation_fill_mode = Some(match animation.fill_mode {
65+
animation::AnimationFillMode::Forwards => style_property_enum::ArkUI_AnimationFillMode::ARKUI_ANIMATION_FILL_MODE_FORWARDS,
66+
animation::AnimationFillMode::Backwards => style_property_enum::ArkUI_AnimationFillMode::ARKUI_ANIMATION_FILL_MODE_BACKWARDS,
67+
animation::AnimationFillMode::Both => style_property_enum::ArkUI_AnimationFillMode::ARKUI_ANIMATION_FILL_MODE_BOTH,
68+
animation::AnimationFillMode::None => style_property_enum::ArkUI_AnimationFillMode::ARKUI_ANIMATION_FILL_MODE_NONE,
69+
});
70+
6271
animation_timeing_function = Some(match animation.timing_function {
6372
// EasingFunction::Linear => AnimationTimingFunction::AnimationCurve(style_property_enum::ArkUI_AnimationCurve::ARKUI_CURVE_LINEAR),
6473
// EasingFunction::Ease =>AnimationTimingFunction::AnimationCurve( style_property_enum::ArkUI_AnimationCurve::ARKUI_CURVE_EASE),
@@ -111,6 +120,7 @@ impl From<(String, &Property<'_>, Option<Rc<RefCell<HashMap<String, Vec<KeyFrame
111120
animation_name,
112121
animation_duration,
113122
animation_delay,
123+
animation_fill_mode,
114124
animation_iteration,
115125
animation_timeing_function
116126
}
@@ -132,6 +142,9 @@ impl ToExpr for Animation {
132142
if let Some(duration) = self.animation_duration {
133143
exprs.push((CSSPropertyType::AnimationDuration, generate_expr_lit_num!((duration * 1000.0) as f64)))
134144
}
145+
if let Some(fill_mode) = &self.animation_fill_mode {
146+
exprs.push((CSSPropertyType::AnimationFillMode, generate_expr_enum!(*fill_mode)));
147+
}
135148
if let Some(timeing_function) = &self.animation_timeing_function {
136149
match timeing_function {
137150
AnimationTimingFunction::AnimationCurve(timeing_function) => {

0 commit comments

Comments
 (0)