Skip to content

Commit 7510439

Browse files
authored
editor animations addon -- now we can patch custom modals
1 parent 357d2cc commit 7510439

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
// By: SharkPool
33
// By: reflow <https://github.com/mgikdev>
44

5-
/* TODO
6-
- patch custom modal api when added
7-
- patch adding modals from addons (they dont use react)
8-
*/
9-
105
export default async function({ addon }) {
116
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
127
const addonKey = "addonAnimations-";
@@ -40,8 +35,7 @@ export default async function({ addon }) {
4035
"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%)",
4136
};
4237
const hasNoVariation = ["default", "fastInSlowOut", "smoothStep", "elastic", "bounce", "emphasis"];
43-
44-
38+
4539
let needsInit = true, animateModals = true, animateLibraries = true, animateButtons = true,
4640
animationSpeed = 1, animationType = "default", animationDir = "InOut";
4741
let patchedBody = false, sbPatched = false, sbEverPatched = false, listenerAttached = false;
@@ -394,6 +388,14 @@ export default async function({ addon }) {
394388
attachCloseHijack("modal");
395389
}
396390

391+
const ogSBCustomPrompt = ScratchBlocks.prompt;
392+
ScratchBlocks.customPrompt = function(...args) {
393+
ogSBCustomPrompt.call(this, ...args);
394+
395+
handleOpenAnimation("modal");
396+
attachCloseHijack("modal");
397+
}
398+
397399
if (sbEverPatched) return;
398400
sbEverPatched = true;
399401

0 commit comments

Comments
 (0)