|
1 | | -import React from "react"; |
| 1 | +import React, { useEffect } from "react"; |
2 | 2 | import clock from "../../../../assets/preview/clock.svg"; |
3 | 3 | import pin from "../../../../assets/preview/map-pin.svg"; |
4 | 4 | import right from "../../../../assets/preview/keyboard_arrow_right.svg"; |
@@ -48,8 +48,40 @@ const PreviewModal: React.FC<PreviewModalProps> = ({ |
48 | 48 | const waitingCount = Number(localStorage.getItem("waitingCount")); |
49 | 49 | console.log(boothIntro, "게시글"); |
50 | 50 |
|
| 51 | + useEffect(() => { |
| 52 | + const body = document.body; |
| 53 | + const scrollY = |
| 54 | + window.scrollY || |
| 55 | + window.pageYOffset || |
| 56 | + document.documentElement.scrollTop || |
| 57 | + 0; |
| 58 | + |
| 59 | + // 스크롤바 사라져서 레이아웃 점프 방지용 padding-right |
| 60 | + const scrollbarW = window.innerWidth - document.documentElement.clientWidth; |
| 61 | + |
| 62 | + body.style.position = "fixed"; |
| 63 | + body.style.top = `-${scrollY}px`; |
| 64 | + body.style.left = "0"; |
| 65 | + body.style.right = "0"; |
| 66 | + body.style.width = "100%"; |
| 67 | + body.style.overflow = "hidden"; |
| 68 | + if (scrollbarW > 0) body.style.paddingRight = `${scrollbarW}px`; |
| 69 | + |
| 70 | + return () => { |
| 71 | + // 원복 + 원래 위치로 스크롤 복구 |
| 72 | + body.style.position = ""; |
| 73 | + body.style.top = ""; |
| 74 | + body.style.left = ""; |
| 75 | + body.style.right = ""; |
| 76 | + body.style.width = ""; |
| 77 | + body.style.overflow = ""; |
| 78 | + body.style.paddingRight = ""; |
| 79 | + window.scrollTo(0, scrollY); |
| 80 | + }; |
| 81 | + }, []); |
| 82 | + |
51 | 83 | return ( |
52 | | - <div className="fixed inset-0 bg-black/40 flex items-center justify-center z-50"> |
| 84 | + <div className="fixed inset-0 bg-black/40 flex items-center justify-center z-50 overscroll-contain"> |
53 | 85 | <div className="flex flex-col items-center bg-white rounded-[20px] w-[372px] h-[706px] p-[30px] "> |
54 | 86 | <h2 className="text-title-20-bold text-black-85 mb-[10px] text-center"> |
55 | 87 | 화면 미리보기 |
@@ -100,13 +132,13 @@ const PreviewModal: React.FC<PreviewModalProps> = ({ |
100 | 132 | </span> |
101 | 133 | {/* 게시글 */} |
102 | 134 | <div |
103 | | - className="h-[98px] mt-[15.43px] mb-[28.5px] text-10-regular" |
| 135 | + className="h-[98px] mt-[15.43px] mb-[28.5px] text-10-regular overflow-y-auto" |
104 | 136 | dangerouslySetInnerHTML={{ |
105 | 137 | __html: DOMPurify.sanitize(boothIntro.replace(/\n/g, "<br />")), |
106 | 138 | }} |
107 | 139 | ></div> |
108 | 140 | {/* 공지 알림 */} |
109 | | - <div className="flex items-center justify-between w-full rounded-[6.29px] px-[10px] py-[8.81px] bg-black-10 border-[#ECECEC] border-[0.63px]"> |
| 141 | + <div className="flex items-center justify-between w-full rounded-[6.29px] px-[10px] py-[8.81px] bg-black-10 border-[#ECECEC] border-[0.63px] "> |
110 | 142 | <p className="text-notice-medium text-black-70 truncate"> |
111 | 143 | <span className="text-black-50 text-notice mr-[3.78px]"> |
112 | 144 | 공지 |
|
0 commit comments