@webitel/ui-chats 0.1.41 → 0.1.42
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/package.json
CHANGED
|
@@ -50,6 +50,8 @@ export const useChatScroll = ({
|
|
|
50
50
|
let lastVisibleMessageEl: HTMLElement | null = null;
|
|
51
51
|
let prevScrollHeight = 0;
|
|
52
52
|
let resizeObserver: ResizeObserver | null = null;
|
|
53
|
+
let isViewportTransition = false;
|
|
54
|
+
let viewportTransitionTimer: ReturnType<typeof setTimeout> | null = null;
|
|
53
55
|
/**
|
|
54
56
|
* @author PolinaSukhorukova-webitel
|
|
55
57
|
*
|
|
@@ -113,6 +115,12 @@ export const useChatScroll = ({
|
|
|
113
115
|
|
|
114
116
|
const newScrollHeight = el.scrollHeight;
|
|
115
117
|
|
|
118
|
+
if (isViewportTransition) {
|
|
119
|
+
prevScrollHeight = newScrollHeight;
|
|
120
|
+
updateScrollToBottomBtnVisibility(el);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
116
124
|
const wasNearBottom =
|
|
117
125
|
el.scrollTop + el.clientHeight >= prevScrollHeight - bottomThreshold;
|
|
118
126
|
const contentGrown = newScrollHeight > prevScrollHeight;
|
|
@@ -157,6 +165,26 @@ export const useChatScroll = ({
|
|
|
157
165
|
resetScrollToBottomBtn();
|
|
158
166
|
};
|
|
159
167
|
|
|
168
|
+
const onFullscreenChange = () => {
|
|
169
|
+
isViewportTransition = true;
|
|
170
|
+
|
|
171
|
+
if (viewportTransitionTimer) clearTimeout(viewportTransitionTimer);
|
|
172
|
+
|
|
173
|
+
viewportTransitionTimer = setTimeout(() => {
|
|
174
|
+
isViewportTransition = false;
|
|
175
|
+
viewportTransitionTimer = null;
|
|
176
|
+
}, 500);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @author PolinaSukhorukova-webitel
|
|
181
|
+
*
|
|
182
|
+
* WTEL-9968 (https://webitel.atlassian.net/browse/WTEL-9968)
|
|
183
|
+
* to avoid extra bottom scroll when chat is in fullscreen
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
document.addEventListener('fullscreenchange', onFullscreenChange);
|
|
187
|
+
|
|
160
188
|
watch(
|
|
161
189
|
() => messages.value?.length,
|
|
162
190
|
(newValue, oldValue) => {
|
|
@@ -215,6 +243,8 @@ export const useChatScroll = ({
|
|
|
215
243
|
|
|
216
244
|
onUnmounted(() => {
|
|
217
245
|
stopStickToBottomObserving();
|
|
246
|
+
document.removeEventListener('fullscreenchange', onFullscreenChange);
|
|
247
|
+
if (viewportTransitionTimer) clearTimeout(viewportTransitionTimer);
|
|
218
248
|
});
|
|
219
249
|
|
|
220
250
|
return {
|
|
@@ -12,6 +12,19 @@ export const useObserveHeightUntilStable = (
|
|
|
12
12
|
callback: () => void,
|
|
13
13
|
) => {
|
|
14
14
|
let observer: ResizeObserver | null = null;
|
|
15
|
+
let isViewportTransition = false;
|
|
16
|
+
let viewportTransitionTimer: ReturnType<typeof setTimeout> | null = null;
|
|
17
|
+
|
|
18
|
+
const onFullscreenChange = () => {
|
|
19
|
+
isViewportTransition = true;
|
|
20
|
+
|
|
21
|
+
if (viewportTransitionTimer) clearTimeout(viewportTransitionTimer);
|
|
22
|
+
|
|
23
|
+
viewportTransitionTimer = setTimeout(() => {
|
|
24
|
+
isViewportTransition = false;
|
|
25
|
+
viewportTransitionTimer = null;
|
|
26
|
+
}, 500);
|
|
27
|
+
};
|
|
15
28
|
|
|
16
29
|
const stopObserve = () => {
|
|
17
30
|
observer?.disconnect();
|
|
@@ -26,7 +39,8 @@ export const useObserveHeightUntilStable = (
|
|
|
26
39
|
|
|
27
40
|
observer = new ResizeObserver(() => {
|
|
28
41
|
const currentClientHeight = chatContainer.value?.clientHeight;
|
|
29
|
-
|
|
42
|
+
|
|
43
|
+
if (!isViewportTransition) callback();
|
|
30
44
|
|
|
31
45
|
if (currentClientHeight === lastClientHeight) {
|
|
32
46
|
stableCount++;
|
|
@@ -40,7 +54,19 @@ export const useObserveHeightUntilStable = (
|
|
|
40
54
|
observer.observe(chatContainer.value);
|
|
41
55
|
};
|
|
42
56
|
|
|
43
|
-
|
|
57
|
+
/**
|
|
58
|
+
* @author PolinaSukhorukova-webitel
|
|
59
|
+
*
|
|
60
|
+
* WTEL-9968 (https://webitel.atlassian.net/browse/WTEL-9968)
|
|
61
|
+
* to avoid extra bottom scroll when chat is in fullscreen
|
|
62
|
+
*/
|
|
63
|
+
document.addEventListener('fullscreenchange', onFullscreenChange);
|
|
64
|
+
|
|
65
|
+
onUnmounted(() => {
|
|
66
|
+
stopObserve();
|
|
67
|
+
document.removeEventListener('fullscreenchange', onFullscreenChange);
|
|
68
|
+
if (viewportTransitionTimer) clearTimeout(viewportTransitionTimer);
|
|
69
|
+
});
|
|
44
70
|
|
|
45
71
|
return {
|
|
46
72
|
startObserve,
|