Skip to content

Commit 77e334a

Browse files
add more animations to editor animations addon
1 parent 4943450 commit 77e334a

File tree

2 files changed

+45
-24
lines changed

2 files changed

+45
-24
lines changed

src/addons/addons/editor-animations/_manifest_entry.js

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ const manifest = {
1717
"type": "notice",
1818
"text": "This addon will not take effect if you have animations turned off on your system. See https://mgik.dev/turn-on-motion for how to turn it on.",
1919
"id": "reduced-motion-notice"
20+
},
21+
{
22+
"type": "notice",
23+
"text": "Some animation types don't support animation direction; therefore, the animation direction may be ignored.",
24+
"id": "animation-support"
2025
}
2126
],
2227
"settings": [
@@ -58,26 +63,30 @@ const manifest = {
5863
"default": "default",
5964
"potentialValues": [
6065
{ "id": "default", "name": "Default" },
61-
{ "id": "easeIn", "name": "Ease In" },
62-
{ "id": "easeOut", "name": "Ease Out" },
63-
{ "id": "easeInOut", "name": "Ease In Out" },
66+
{ "id": "ease", "name": "Ease" },
6467
{ "id": "smoothStep", "name": "Smooth Step" },
6568
{ "id": "fastInSlowOut", "name": "Fast In Slow Out" },
66-
{ "id": "sineIn", "name": "Sine In" },
67-
{ "id": "sineOut", "name": "Sine Out" },
68-
{ "id": "sineInOut", "name": "Sine In Out" },
69-
{ "id": "quadIn", "name": "Quadratic In" },
70-
{ "id": "quadOut", "name": "Quadratic Out" },
71-
{ "id": "quadInOut", "name": "Quadratic In Out" },
72-
{ "id": "cubicIn", "name": "Cubic In" },
73-
{ "id": "cubicOut", "name": "Cubic Out" },
74-
{ "id": "cubicInOut", "name": "Cubic In Out" },
75-
{ "id": "quartIn", "name": "Quartic In" },
76-
{ "id": "quartOut", "name": "Quartic Out" },
77-
{ "id": "quartInOut", "name": "Quartic In Out" },
78-
{ "id": "quintIn", "name": "Quintic In" },
79-
{ "id": "quintOut", "name": "Quintic Out" },
80-
{ "id": "quintInOut", "name": "Quintic In Out" }
69+
{ "id": "sine", "name": "Sine" },
70+
{ "id": "quad", "name": "Quadratic" },
71+
{ "id": "cubic", "name": "Cubic" },
72+
{ "id": "quart", "name": "Quartic" },
73+
{ "id": "quint", "name": "Quintic" },
74+
{ "id": "back", "name": "Back" },
75+
{ "id": "elastic", "name": "Elastic" },
76+
{ "id": "bounce", "name": "Bounce" },
77+
{ "id": "emphasis", "name": "Emphasis" },
78+
]
79+
},
80+
{
81+
"id": "animationDir",
82+
"name": "Animation Direction",
83+
"type": "select",
84+
"dynamic": true,
85+
"default": "InOut",
86+
"potentialValues": [
87+
{ "id": "In", "name": "In" },
88+
{ "id": "Out", "name": "Out" },
89+
{ "id": "InOut", "name": "Both" },
8190
]
8291
},
8392
],

src/addons/addons/editor-animations/userscript.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Editor Animations (remake of Reactive Animation by <https://github.com/mmmmaaaaarrrrrrkkkkkkkk>)
22
// By: SharkPool
3-
// By: reflow <https://github.com/mmmmaaaaarrrrrrkkkkkkkk>
3+
// By: reflow <https://github.com/mgikdev>
44

55
/* TODO
66
- patch custom modal api when added
@@ -31,11 +31,19 @@ export default async function({ addon }) {
3131
"quartInOut": "cubic-bezier(0.77, 0, 0.175, 1)",
3232
"quintIn": "cubic-bezier(0.755, 0.05, 0.855, 0.06)",
3333
"quintOut": "cubic-bezier(0.23, 1, 0.32, 1)",
34-
"quintInOut": "cubic-bezier(0.86, 0, 0.07, 1)"
34+
"quintInOut": "cubic-bezier(0.86, 0, 0.07, 1)",
35+
"backIn": "cubic-bezier(0.6, -0.28, 0.74, 0.05)",
36+
"backOut": "cubic-bezier(0.18, 0.89, 0.32, 1.28)",
37+
"backInOut": "cubic-bezier(0.68, -0.55, 0.27, 1.55)",
38+
"elastic": "linear(0 0%, 0.22 2.1%, 0.86 6.5%, 1.11 8.6%, 1.3 10.7%, 1.35 11.8%, 1.37 12.9%, 1.37 13.7%, 1.36 14.5%, 1.32 16.2%, 1.03 21.8%, 0.94 24%, 0.89 25.9%, 0.88 26.85%, 0.87 27.8%, 0.87 29.25%, 0.88 30.7%, 0.91 32.4%, 0.98 36.4%, 1.01 38.3%, 1.04 40.5%, 1.05 42.7%, 1.05 44.1%, 1.04 45.7%, 1 53.3%, 0.99 55.4%, 0.98 57.5%, 0.99 60.7%, 1 68.1%, 1.01 72.2%, 1 86.7%, 1 100%)",
39+
"bounce": "linear(0 0%, 0 2.27%, 0.02 4.53%, 0.04 6.8%, 0.06 9.07%, 0.1 11.33%, 0.14 13.6%, 0.25 18.15%, 0.39 22.7%, 0.56 27.25%, 0.77 31.8%, 1 36.35%, 0.89 40.9%, 0.85 43.18%, 0.81 45.45%, 0.79 47.72%, 0.77 50%, 0.75 52.27%, 0.75 54.55%, 0.75 56.82%, 0.77 59.1%, 0.79 61.38%, 0.81 63.65%, 0.85 65.93%, 0.89 68.2%, 1 72.7%, 0.97 74.98%, 0.95 77.25%, 0.94 79.53%, 0.94 81.8%, 0.94 84.08%, 0.95 86.35%, 0.97 88.63%, 1 90.9%, 0.99 93.18%, 0.98 95.45%, 0.99 97.73%, 1 100%)",
40+
"emphasis": "linear(0 0%, 0 1.8%, 0.01 3.6%, 0.03 6.35%, 0.07 9.1%, 0.13 11.4%, 0.19 13.4%, 0.27 15%, 0.34 16.1%, 0.54 18.35%, 0.66 20.6%, 0.72 22.4%, 0.77 24.6%, 0.81 27.3%, 0.85 30.4%, 0.88 35.1%, 0.92 40.6%, 0.94 47.2%, 0.96 55%, 0.98 64%, 0.99 74.4%, 1 86.4%, 1 100%)",
3541
};
36-
42+
const hasNoVariation = ["default", "fastInSlowOut", "smoothStep", "elastic", "bounce", "emphasis"];
43+
44+
3745
let needsInit = true, animateModals = true, animateLibraries = true, animateButtons = true,
38-
animationSpeed = 1, animationType = "default";
46+
animationSpeed = 1, animationType = "default", animationDir = "InOut";
3947
let patchedBody = false, sbPatched = false, sbEverPatched = false, listenerAttached = false;
4048

4149
const genStyles = () => `
@@ -140,14 +148,18 @@ export default async function({ addon }) {
140148
animateLibraries = addon.settings.get("animateLibraries");
141149
animateButtons = addon.settings.get("animateButtons");
142150
animationType = addon.settings.get("animationType");
143-
151+
animationDir = addon.settings.get("animationDir");
144152
const oldSpeed = animationSpeed;
145153
animationSpeed = 1 / (Number(addon.settings.get("animateSpeed")) / 100);
146154
if (oldSpeed !== animationSpeed) styleElement.textContent = genStyles();
147155
}
148156

149157
function getEasing() {
150-
return animationTypes[animationType];
158+
if (hasNoVariation.includes(animationType)) {
159+
return animationTypes[animationType];
160+
} else {
161+
return animationTypes[animationType + animationDir];
162+
}
151163
}
152164

153165
function getAnim(time) {

0 commit comments

Comments
 (0)