Skip to content

Commit af9f62e

Browse files
authored
editor animations addon -- animation speed internals (1/2)
1 parent 21a77b8 commit af9f62e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export default async function({ addon }) {
1111
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
1212
const addonKey = "addonAnimations-";
1313
const cubicAnimation = "cubic-bezier(0.63, 0.32, 0.08, 0.95)";
14-
const getAnim = (time) => { return `${time}s ${cubicAnimation}` };
1514

1615
const styles = `
1716
/* Top Bar Items */
@@ -110,15 +109,21 @@ export default async function({ addon }) {
110109
animationEnabled = !e.matches;
111110
});
112111

113-
let needsInit = true, animateModals = true, animateLibraries = true, animateButtons = true;
112+
let needsInit = true, animateModals = true, animateLibraries = true, animateButtons = true, animationSpeed = 1;
114113
let patchedBody = false, sbPatched = false, sbEverPatched = false, listenerAttached = false;
115114

116115
function requestAddonState() {
117116
animateModals = addon.settings.get("animateModals");
118117
animateLibraries = addon.settings.get("animateLibraries");
119118
animateButtons = addon.settings.get("animateButtons");
119+
animationSpeed = Number(addon.settings.get("animateSpeed")) / 100;
120120
}
121121

122+
function getAnim(time) {
123+
time *= animationSpeed;
124+
return `${time}s ${cubicAnimation}`;
125+
};
126+
122127
function observeMenuScalers(element, observerSub, observerAtt) {
123128
if (!animateModals) return;
124129
if (element.hasAttribute("addon-scale-listeners-bound")) return;

0 commit comments

Comments
 (0)