0
0
Fork 0

Move app/javascript/hooks to app/javascript/mastodon/hooks (#34077)

This commit is contained in:
Claire 2025-03-05 17:55:53 +01:00 committed by GitHub
parent 00dbefdbbf
commit b57687083f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 15 additions and 17 deletions

View file

@ -1,32 +0,0 @@
// This hook allows a component to signal that it's done rendering in a way that
// can be used by e.g. our embed code to determine correct iframe height
let renderSignalReceived = false;
type Callback = () => void;
let onInitialRender: Callback;
export const afterInitialRender = (callback: Callback) => {
if (renderSignalReceived) {
callback();
} else {
onInitialRender = callback;
}
};
export const useRenderSignal = () => {
return () => {
if (renderSignalReceived) {
return;
}
renderSignalReceived = true;
if (typeof onInitialRender !== 'undefined') {
window.requestAnimationFrame(() => {
onInitialRender();
});
}
};
};