Skip to content

Commit 2fe6a2f

Browse files
committed
feat: 支持解析animation
1 parent 0bb6a8c commit 2fe6a2f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/style_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<'i> Visitor<'i> for StyleVisitor<'i> {
107107
percentage.0
108108
}
109109
KeyframeSelector::From => 0.0,
110-
KeyframeSelector::To => 100.0,
110+
KeyframeSelector::To => 1.0,
111111
},
112112
declarations: parse_style_properties(&properties, None)
113113
};

src/style_propetries/animation.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{cell::RefCell, collections::HashMap, rc::Rc};
44

55
use lightningcss::{printer::PrinterOptions, properties::{animation, Property}, traits::ToCss, values::{easing::EasingFunction, time}};
66

7-
use crate::{generate_expr_lit_num, generate_invalid_expr, style_parser::KeyFrameItem, visitor::parse_style_values};
7+
use crate::{generate_expr_lit_num, generate_expr_lit_str, generate_invalid_expr, style_parser::KeyFrameItem, visitor::parse_style_values};
88
use swc_core::{common::DUMMY_SP, ecma::ast::*};
99
use super::{traits::ToExpr, unit::{Platform, PropertyTuple}};
1010

@@ -128,6 +128,10 @@ impl ToExpr for Animation {
128128
key: PropName::Str("duration".into()),
129129
value: Box::new(generate_expr_lit_num!(item_duration as f64))
130130
}))),
131+
PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
132+
key: PropName::Str("curve".into()),
133+
value: Box::new(generate_expr_lit_str!(self.animation_timeing_function.to_css_string(PrinterOptions::default()).unwrap()))
134+
}))),
131135
PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
132136
key: PropName::Str("event".into()),
133137
value: Box::new(Expr::Object(ObjectLit {

0 commit comments

Comments
 (0)