Files
vercel__streamdown/packages/streamdown/lib/scroll-lock.ts
Udit Kumar fb76275ef4 Feat/table fullscreen (#390)
* feat(streamdown): add fullscreen support for tables

* test(streamdown): add fullscreen behavior tests

* docs: document fullscreen styling and usage

* add: changeset

* fix: prevent unintended fullscreen close

* fix: resolve shiki theme style mapping

---------

Co-authored-by: Hayden Bleasel <hello@haydenbleasel.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 16:16:10 -08:00

18 lines
475 B
TypeScript

// Shared scroll lock utility with reference counting.
// Prevents bugs when multiple overlays (e.g. link modal inside fullscreen) are open simultaneously.
let activeCount = 0;
export const lockBodyScroll = () => {
activeCount += 1;
if (activeCount === 1) {
document.body.style.overflow = "hidden";
}
};
export const unlockBodyScroll = () => {
activeCount = Math.max(0, activeCount - 1);
if (activeCount === 0) {
document.body.style.overflow = "";
}
};