Skip to content

Commit

Permalink
added setBackgroundColorOnScale prop (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
cervantes-x committed May 7, 2024
1 parent 9eab0b0 commit 8f1cd88
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type DialogProps = {
closeThreshold?: number;
onOpenChange?: (open: boolean) => void;
shouldScaleBackground?: boolean;
setBackgroundColorOnScale?: boolean;
scrollLockTimeout?: number;
fixed?: boolean;
dismissible?: boolean;
Expand All @@ -65,6 +66,7 @@ function Root({
onRelease: onReleaseProp,
snapPoints,
nested = false,
setBackgroundColorOnScale = true,
closeThreshold = CLOSE_THRESHOLD,
scrollLockTimeout = SCROLL_LOCK_TIMEOUT,
dismissible = true,
Expand Down Expand Up @@ -611,18 +613,20 @@ function Root({
if (!wrapper || !shouldScaleBackground) return;

if (open) {
// setting original styles initially
set(document.body, {
background: document.body.style.backgroundColor || document.body.style.background,
});
// setting body styles, with cache ignored, so that we can get correct original styles in reset
set(
document.body,
{
background: 'black',
},
true,
);
if (setBackgroundColorOnScale) {
// setting original styles initially
set(document.body, {
background: document.body.style.backgroundColor || document.body.style.background,
});
// setting body styles, with cache ignored, so that we can get correct original styles in reset
set(
document.body,
{
background: 'black',
},
true,
);
}

set(wrapper, {
borderRadius: `${BORDER_RADIUS}px`,
Expand Down

0 comments on commit 8f1cd88

Please sign in to comment.