@myun/gimi-chat 0.9.3 → 0.9.4
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.
|
@@ -215,6 +215,11 @@ var MessageList = function MessageList(_ref) {
|
|
|
215
215
|
useVirtualScroll = _useState4[0],
|
|
216
216
|
setUseVirtualScroll = _useState4[1];
|
|
217
217
|
var VIRTUAL_SCROLL_THRESHOLD = 1200;
|
|
218
|
+
var isSafari = useMemo(function () {
|
|
219
|
+
if (typeof navigator === 'undefined') return false;
|
|
220
|
+
var ua = navigator.userAgent;
|
|
221
|
+
return /Safari/i.test(ua) && !/Chrome|Chromium|Edg/i.test(ua);
|
|
222
|
+
}, []);
|
|
218
223
|
useEffect(function () {
|
|
219
224
|
if (containerRef.current && containerRef.current !== scrollParent) {
|
|
220
225
|
setScrollParent(containerRef.current);
|
|
@@ -281,7 +286,7 @@ var MessageList = function MessageList(_ref) {
|
|
|
281
286
|
className: classNames(styles.container)
|
|
282
287
|
}, visibleChatList.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
283
288
|
className: styles.textWrap
|
|
284
|
-
}, useVirtualScroll && scrollParent && platform === 'myun' ? /*#__PURE__*/React.createElement(Virtuoso, {
|
|
289
|
+
}, useVirtualScroll && scrollParent && platform === 'myun' && !isSafari ? /*#__PURE__*/React.createElement(Virtuoso, {
|
|
285
290
|
style: {
|
|
286
291
|
height: '100%',
|
|
287
292
|
minHeight: 1
|
package/dist/hooks/useScroll.js
CHANGED
|
@@ -28,7 +28,8 @@ var useScroll = function useScroll(containerRef) {
|
|
|
28
28
|
lastScrollTop: 0,
|
|
29
29
|
isUserInteracting: false,
|
|
30
30
|
wasAtBottom: true,
|
|
31
|
-
lastWheelAt: 0
|
|
31
|
+
lastWheelAt: 0,
|
|
32
|
+
lastScrollAt: 0
|
|
32
33
|
}).current;
|
|
33
34
|
var scrollBottomNow = React.useCallback(function () {
|
|
34
35
|
var tries = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4;
|
|
@@ -123,9 +124,9 @@ var useScroll = function useScroll(containerRef) {
|
|
|
123
124
|
var canScroll = scrollHeight - clientHeight > 1;
|
|
124
125
|
if (!canScroll) return;
|
|
125
126
|
var position = Math.max(0, scrollHeight - clientHeight - scrollTop);
|
|
126
|
-
if (e.deltaY <
|
|
127
|
+
if (e.deltaY < 0) {
|
|
127
128
|
markUserInteraction(true);
|
|
128
|
-
} else if (e.deltaY >
|
|
129
|
+
} else if (e.deltaY > 0 && position <= bottomPosition) {
|
|
129
130
|
markUserInteraction(false);
|
|
130
131
|
}
|
|
131
132
|
}, 100), [containerRef.current, bottomPosition, markUserInteraction, refs]);
|
|
@@ -139,13 +140,11 @@ var useScroll = function useScroll(containerRef) {
|
|
|
139
140
|
setCurrentPosition(position);
|
|
140
141
|
setIsScrolling(true);
|
|
141
142
|
refs.wasAtBottom = position <= bottomPosition * 2;
|
|
143
|
+
refs.lastScrollAt = Date.now();
|
|
142
144
|
var scrollDelta = scrollTop - refs.lastScrollTop;
|
|
143
|
-
if (Math.abs(scrollDelta) >
|
|
145
|
+
if (Math.abs(scrollDelta) > 0.5) {
|
|
144
146
|
if (scrollDelta < 0) {
|
|
145
|
-
|
|
146
|
-
if (refs.isUserInteracting || now - refs.lastWheelAt < 600) {
|
|
147
|
-
markUserInteraction(true);
|
|
148
|
-
}
|
|
147
|
+
markUserInteraction(true);
|
|
149
148
|
} else if (scrollDelta > 0 && position <= bottomPosition) {
|
|
150
149
|
markUserInteraction(false);
|
|
151
150
|
}
|
|
@@ -194,6 +193,8 @@ var useScroll = function useScroll(containerRef) {
|
|
|
194
193
|
}
|
|
195
194
|
;
|
|
196
195
|
if (refs.isUserInteracting) return;
|
|
196
|
+
var now = Date.now();
|
|
197
|
+
if (now - refs.lastWheelAt < 200 || now - refs.lastScrollAt < 200) return;
|
|
197
198
|
if (refs.wasAtBottom || distanceToBottom <= bottomPosition * 5) {
|
|
198
199
|
scrollBottomNow(4);
|
|
199
200
|
}
|