@tp3/chat-widget 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ChatWidget.js +15 -3
- package/dist/ChatWidget.mjs +15 -3
- package/package.json +1 -1
- package/src/ChatWidget.tsx +20 -7
package/dist/ChatWidget.js
CHANGED
|
@@ -66,14 +66,26 @@ function ChatWidget({
|
|
|
66
66
|
const inputRef = (0, import_react.useRef)(null);
|
|
67
67
|
const typewriterQueue = (0, import_react.useRef)([]);
|
|
68
68
|
const typewriterTimer = (0, import_react.useRef)(null);
|
|
69
|
+
const savedScrollY = (0, import_react.useRef)(0);
|
|
69
70
|
(0, import_react.useEffect)(() => {
|
|
70
71
|
if (open && !closing) {
|
|
71
|
-
|
|
72
|
+
savedScrollY.current = window.scrollY;
|
|
73
|
+
document.body.style.position = "fixed";
|
|
74
|
+
document.body.style.top = `-${savedScrollY.current}px`;
|
|
75
|
+
document.body.style.left = "0";
|
|
76
|
+
document.body.style.right = "0";
|
|
72
77
|
} else {
|
|
73
|
-
document.
|
|
78
|
+
document.body.style.position = "";
|
|
79
|
+
document.body.style.top = "";
|
|
80
|
+
document.body.style.left = "";
|
|
81
|
+
document.body.style.right = "";
|
|
82
|
+
window.scrollTo(0, savedScrollY.current);
|
|
74
83
|
}
|
|
75
84
|
return () => {
|
|
76
|
-
document.
|
|
85
|
+
document.body.style.position = "";
|
|
86
|
+
document.body.style.top = "";
|
|
87
|
+
document.body.style.left = "";
|
|
88
|
+
document.body.style.right = "";
|
|
77
89
|
};
|
|
78
90
|
}, [open, closing]);
|
|
79
91
|
(0, import_react.useEffect)(() => {
|
package/dist/ChatWidget.mjs
CHANGED
|
@@ -42,14 +42,26 @@ function ChatWidget({
|
|
|
42
42
|
const inputRef = useRef(null);
|
|
43
43
|
const typewriterQueue = useRef([]);
|
|
44
44
|
const typewriterTimer = useRef(null);
|
|
45
|
+
const savedScrollY = useRef(0);
|
|
45
46
|
useEffect(() => {
|
|
46
47
|
if (open && !closing) {
|
|
47
|
-
|
|
48
|
+
savedScrollY.current = window.scrollY;
|
|
49
|
+
document.body.style.position = "fixed";
|
|
50
|
+
document.body.style.top = `-${savedScrollY.current}px`;
|
|
51
|
+
document.body.style.left = "0";
|
|
52
|
+
document.body.style.right = "0";
|
|
48
53
|
} else {
|
|
49
|
-
document.
|
|
54
|
+
document.body.style.position = "";
|
|
55
|
+
document.body.style.top = "";
|
|
56
|
+
document.body.style.left = "";
|
|
57
|
+
document.body.style.right = "";
|
|
58
|
+
window.scrollTo(0, savedScrollY.current);
|
|
50
59
|
}
|
|
51
60
|
return () => {
|
|
52
|
-
document.
|
|
61
|
+
document.body.style.position = "";
|
|
62
|
+
document.body.style.top = "";
|
|
63
|
+
document.body.style.left = "";
|
|
64
|
+
document.body.style.right = "";
|
|
53
65
|
};
|
|
54
66
|
}, [open, closing]);
|
|
55
67
|
useEffect(() => {
|
package/package.json
CHANGED
package/src/ChatWidget.tsx
CHANGED
|
@@ -67,18 +67,31 @@ export default function ChatWidget({
|
|
|
67
67
|
const typewriterQueue = useRef<string[]>([]);
|
|
68
68
|
const typewriterTimer = useRef<ReturnType<typeof setInterval> | null>(null);
|
|
69
69
|
|
|
70
|
-
// Lock scroll on the page behind the chat
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
70
|
+
// Lock scroll on the page behind the chat without blocking scroll
|
|
71
|
+
// inside the chat messages area. Uses position:fixed on body — the
|
|
72
|
+
// chat window is also fixed, so it stays visible and its internal
|
|
73
|
+
// overflow-y:auto container scrolls independently.
|
|
74
|
+
const savedScrollY = useRef(0);
|
|
75
|
+
|
|
74
76
|
useEffect(() => {
|
|
75
77
|
if (open && !closing) {
|
|
76
|
-
|
|
78
|
+
savedScrollY.current = window.scrollY;
|
|
79
|
+
document.body.style.position = "fixed";
|
|
80
|
+
document.body.style.top = `-${savedScrollY.current}px`;
|
|
81
|
+
document.body.style.left = "0";
|
|
82
|
+
document.body.style.right = "0";
|
|
77
83
|
} else {
|
|
78
|
-
document.
|
|
84
|
+
document.body.style.position = "";
|
|
85
|
+
document.body.style.top = "";
|
|
86
|
+
document.body.style.left = "";
|
|
87
|
+
document.body.style.right = "";
|
|
88
|
+
window.scrollTo(0, savedScrollY.current);
|
|
79
89
|
}
|
|
80
90
|
return () => {
|
|
81
|
-
document.
|
|
91
|
+
document.body.style.position = "";
|
|
92
|
+
document.body.style.top = "";
|
|
93
|
+
document.body.style.left = "";
|
|
94
|
+
document.body.style.right = "";
|
|
82
95
|
};
|
|
83
96
|
}, [open, closing]);
|
|
84
97
|
|