ManimCat / frontend /src /components /image-preview /lightbox /useBodyScrollLock.ts
Bin29's picture
Sync from main: e764154 feat(plot-skill): add math-exam-diagram SKILL.md for exam-style math figures
abcf568
import { useEffect } from 'react'
export function useBodyScrollLock(shouldLock: boolean) {
useEffect(() => {
if (!shouldLock || typeof document === 'undefined') {
return undefined;
}
const { body } = document;
const previousOverflow = body.style.overflow;
body.style.overflow = 'hidden';
return () => {
body.style.overflow = previousOverflow;
};
}, [shouldLock]);
}