[frontend/mfm] Add default speed for animation fn nodes
This commit is contained in:
parent
cc156c9760
commit
6e982c95fe
2 changed files with 8 additions and 5 deletions
|
@ -234,7 +234,6 @@
|
||||||
.fn-animation {
|
.fn-animation {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
animation-delay: 0s;
|
animation-delay: 0s;
|
||||||
animation-duration: 1s;
|
|
||||||
animation-fill-mode: both;
|
animation-fill-mode: both;
|
||||||
animation-iteration-count: infinite;
|
animation-iteration-count: infinite;
|
||||||
animation-timing-function: linear;
|
animation-timing-function: linear;
|
||||||
|
|
|
@ -262,8 +262,8 @@ public static partial class MfmRenderer
|
||||||
"blur" => MfmFnBlur(document),
|
"blur" => MfmFnBlur(document),
|
||||||
"jelly" => MfmFnAnimation(node.Name, args, document),
|
"jelly" => MfmFnAnimation(node.Name, args, document),
|
||||||
"tada" => MfmFnAnimation(node.Name, args, document),
|
"tada" => MfmFnAnimation(node.Name, args, document),
|
||||||
"jump" => MfmFnAnimation(node.Name, args, document),
|
"jump" => MfmFnAnimation(node.Name, args, document, "0.75s"),
|
||||||
"bounce" => MfmFnAnimation(node.Name, args, document),
|
"bounce" => MfmFnAnimation(node.Name, args, document, "0.75s"),
|
||||||
"spin" => MfmFnSpin(args, document),
|
"spin" => MfmFnSpin(args, document),
|
||||||
"shake" => throw new NotImplementedException($"{node.Name}"),
|
"shake" => throw new NotImplementedException($"{node.Name}"),
|
||||||
"twitch" => throw new NotImplementedException($"{node.Name}"),
|
"twitch" => throw new NotImplementedException($"{node.Name}"),
|
||||||
|
@ -331,14 +331,18 @@ public static partial class MfmRenderer
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static INode MfmFnAnimation(string name, Dictionary<string, string?> args, IDocument document)
|
private static INode MfmFnAnimation(
|
||||||
|
string name, Dictionary<string, string?> args, IDocument document, string defaultSpeed = "1s"
|
||||||
|
)
|
||||||
{
|
{
|
||||||
var el = document.CreateElement("span");
|
var el = document.CreateElement("span");
|
||||||
|
|
||||||
el.ClassName = "fn-animation";
|
el.ClassName = "fn-animation";
|
||||||
|
|
||||||
var style = $"animation-name: fn-{name}-mfm;";
|
var style = $"animation-name: fn-{name}-mfm;";
|
||||||
style += args.TryGetValue("speed", out var speed) ? $" animation-duration: {speed};" : "";
|
style += args.TryGetValue("speed", out var speed)
|
||||||
|
? $" animation-duration: {speed};"
|
||||||
|
: $" animation-duration: {defaultSpeed};";
|
||||||
style += args.TryGetValue("delay", out var delay) ? $" animation-delay: {delay};" : "";
|
style += args.TryGetValue("delay", out var delay) ? $" animation-delay: {delay};" : "";
|
||||||
style += args.TryGetValue("loop", out var loop) ? $" animation-iteration-count: {loop};" : "";
|
style += args.TryGetValue("loop", out var loop) ? $" animation-iteration-count: {loop};" : "";
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue