|
1 | 1 | // Editor Animations (remake of Reactive Animation by <https://github.com/mmmmaaaaarrrrrrkkkkkkkk>)
|
2 | 2 | // By: SharkPool
|
3 |
| -// By: reflow <https://github.com/mmmmaaaaarrrrrrkkkkkkkk> |
| 3 | +// By: reflow <https://github.com/mgikdev> |
4 | 4 |
|
5 | 5 | /* TODO
|
6 | 6 | - patch custom modal api when added
|
@@ -31,11 +31,19 @@ export default async function({ addon }) {
|
31 | 31 | "quartInOut": "cubic-bezier(0.77, 0, 0.175, 1)",
|
32 | 32 | "quintIn": "cubic-bezier(0.755, 0.05, 0.855, 0.06)",
|
33 | 33 | "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%)", |
35 | 41 | };
|
36 |
| - |
| 42 | + const hasNoVariation = ["default", "fastInSlowOut", "smoothStep", "elastic", "bounce", "emphasis"]; |
| 43 | + |
| 44 | + |
37 | 45 | let needsInit = true, animateModals = true, animateLibraries = true, animateButtons = true,
|
38 |
| - animationSpeed = 1, animationType = "default"; |
| 46 | + animationSpeed = 1, animationType = "default", animationDir = "InOut"; |
39 | 47 | let patchedBody = false, sbPatched = false, sbEverPatched = false, listenerAttached = false;
|
40 | 48 |
|
41 | 49 | const genStyles = () => `
|
@@ -140,14 +148,18 @@ export default async function({ addon }) {
|
140 | 148 | animateLibraries = addon.settings.get("animateLibraries");
|
141 | 149 | animateButtons = addon.settings.get("animateButtons");
|
142 | 150 | animationType = addon.settings.get("animationType");
|
143 |
| - |
| 151 | + animationDir = addon.settings.get("animationDir"); |
144 | 152 | const oldSpeed = animationSpeed;
|
145 | 153 | animationSpeed = 1 / (Number(addon.settings.get("animateSpeed")) / 100);
|
146 | 154 | if (oldSpeed !== animationSpeed) styleElement.textContent = genStyles();
|
147 | 155 | }
|
148 | 156 |
|
149 | 157 | function getEasing() {
|
150 |
| - return animationTypes[animationType]; |
| 158 | + if (hasNoVariation.includes(animationType)) { |
| 159 | + return animationTypes[animationType]; |
| 160 | + } else { |
| 161 | + return animationTypes[animationType + animationDir]; |
| 162 | + } |
151 | 163 | }
|
152 | 164 |
|
153 | 165 | function getAnim(time) {
|
|
0 commit comments