feat: add anim type shorthand + anchor anim

This commit is contained in:
2 * r + 2 * t 2026-04-15 17:31:26 +10:00
parent 90528c513f
commit 7df53a05d0
2 changed files with 94 additions and 2 deletions

51
components/AnchorAnim.qml Normal file
View file

@ -0,0 +1,51 @@
import QtQuick
import Caelestia.Config
AnchorAnimation {
enum Type {
StandardSmall = 0,
Standard,
StandardLarge,
StandardExtraLarge,
EmphasizedSmall,
Emphasized,
EmphasizedLarge,
EmphasizedExtraLarge,
FastSpatial,
DefaultSpatial,
SlowSpatial
}
property int type: AnchorAnim.DefaultSpatial
duration: {
if (type < AnchorAnim.StandardSmall || type > AnchorAnim.SlowSpatial)
return Tokens.anim.durations.expressiveDefaultSpatial;
if (type == AnchorAnim.FastSpatial)
return Tokens.anim.durations.expressiveFastSpatial;
if (type == AnchorAnim.DefaultSpatial)
return Tokens.anim.durations.expressiveDefaultSpatial;
if (type == AnchorAnim.SlowSpatial)
return Tokens.anim.durations.expressiveSlowSpatial;
const types = ["small", "normal", "large", "extraLarge"];
const idx = type % 4; // 0-7 are the 4 standard types
return Tokens.anim.durations[types[idx]];
}
easing: {
if (type == AnchorAnim.FastSpatial)
return Tokens.anim.expressiveFastSpatial;
if (type == AnchorAnim.DefaultSpatial)
return Tokens.anim.expressiveDefaultSpatial;
if (type == AnchorAnim.SlowSpatial)
return Tokens.anim.expressiveSlowSpatial;
if (type >= AnchorAnim.StandardSmall && type <= AnchorAnim.StandardExtraLarge)
return Tokens.anim.standard;
if (type >= AnchorAnim.EmphasizedSmall && type <= AnchorAnim.EmphasizedExtraLarge)
return Tokens.anim.emphasized;
return Tokens.anim.expressiveDefaultSpatial;
}
}

View file

@ -2,6 +2,47 @@ import QtQuick
import Caelestia.Config import Caelestia.Config
NumberAnimation { NumberAnimation {
duration: Tokens.anim.durations.normal enum Type {
easing: Tokens.anim.standard StandardSmall = 0,
Standard,
StandardLarge,
StandardExtraLarge,
EmphasizedSmall,
Emphasized,
EmphasizedLarge,
EmphasizedExtraLarge,
FastSpatial,
DefaultSpatial,
SlowSpatial
}
property int type: Anim.Standard
duration: {
if (type < Anim.StandardSmall || type > Anim.SlowSpatial)
return Tokens.anim.durations.normal;
if (type == Anim.FastSpatial)
return Tokens.anim.durations.expressiveFastSpatial;
if (type == Anim.DefaultSpatial)
return Tokens.anim.durations.expressiveDefaultSpatial;
if (type == Anim.SlowSpatial)
return Tokens.anim.durations.expressiveSlowSpatial;
const types = ["small", "normal", "large", "extraLarge"];
const idx = type % 4; // 0-7 are the 4 standard types
return Tokens.anim.durations[types[idx]];
}
easing: {
if (type == Anim.FastSpatial)
return Tokens.anim.expressiveFastSpatial;
if (type == Anim.DefaultSpatial)
return Tokens.anim.expressiveDefaultSpatial;
if (type == Anim.SlowSpatial)
return Tokens.anim.expressiveSlowSpatial;
if (type >= Anim.EmphasizedSmall && type <= Anim.EmphasizedExtraLarge)
return Tokens.anim.emphasized;
return Tokens.anim.standard;
}
} }