@midscene/visualizer 1.4.8 → 1.4.9

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.
@@ -76,6 +76,8 @@ function usePlaygroundState(playgroundSDK, storage, contextProvider, targetName)
76
76
  const [actionSpaceLoading, setActionSpaceLoading] = useState(true);
77
77
  const [uiContextPreview, setUiContextPreview] = useState();
78
78
  const [showScrollToBottomButton, setShowScrollToBottomButton] = useState(false);
79
+ const [autoScrollEnabled, setAutoScrollEnabled] = useState(true);
80
+ const lastScrollTopRef = useRef(0);
79
81
  const [verticalMode, setVerticalMode] = useState(false);
80
82
  const [replayCounter, setReplayCounter] = useState(0);
81
83
  const infoListRef = useRef(null);
@@ -189,6 +191,10 @@ function usePlaygroundState(playgroundSDK, storage, contextProvider, targetName)
189
191
  const { scrollTop, scrollHeight, clientHeight } = infoListRef.current;
190
192
  const isAtBottom = scrollTop + clientHeight >= scrollHeight - 10;
191
193
  setShowScrollToBottomButton(!isAtBottom);
194
+ const scrollingUp = scrollTop < lastScrollTopRef.current;
195
+ lastScrollTopRef.current = scrollTop;
196
+ if (isAtBottom) setAutoScrollEnabled(true);
197
+ else if (scrollingUp) setAutoScrollEnabled(false);
192
198
  }
193
199
  }, []);
194
200
  const handleScrollToBottom = useCallback(()=>{
@@ -198,13 +204,15 @@ function usePlaygroundState(playgroundSDK, storage, contextProvider, targetName)
198
204
  behavior: 'smooth'
199
205
  });
200
206
  setShowScrollToBottomButton(false);
207
+ setAutoScrollEnabled(true);
201
208
  }
202
209
  }, []);
203
210
  useEffect(()=>{
204
- if (infoList.length > 0) scrollToBottom();
211
+ if (infoList.length > 0 && autoScrollEnabled) scrollToBottom();
205
212
  }, [
206
213
  infoList,
207
- scrollToBottom
214
+ scrollToBottom,
215
+ autoScrollEnabled
208
216
  ]);
209
217
  useEffect(()=>{
210
218
  const container = infoListRef.current;
@@ -104,6 +104,8 @@ function usePlaygroundState(playgroundSDK, storage, contextProvider, targetName)
104
104
  const [actionSpaceLoading, setActionSpaceLoading] = (0, external_react_namespaceObject.useState)(true);
105
105
  const [uiContextPreview, setUiContextPreview] = (0, external_react_namespaceObject.useState)();
106
106
  const [showScrollToBottomButton, setShowScrollToBottomButton] = (0, external_react_namespaceObject.useState)(false);
107
+ const [autoScrollEnabled, setAutoScrollEnabled] = (0, external_react_namespaceObject.useState)(true);
108
+ const lastScrollTopRef = (0, external_react_namespaceObject.useRef)(0);
107
109
  const [verticalMode, setVerticalMode] = (0, external_react_namespaceObject.useState)(false);
108
110
  const [replayCounter, setReplayCounter] = (0, external_react_namespaceObject.useState)(0);
109
111
  const infoListRef = (0, external_react_namespaceObject.useRef)(null);
@@ -217,6 +219,10 @@ function usePlaygroundState(playgroundSDK, storage, contextProvider, targetName)
217
219
  const { scrollTop, scrollHeight, clientHeight } = infoListRef.current;
218
220
  const isAtBottom = scrollTop + clientHeight >= scrollHeight - 10;
219
221
  setShowScrollToBottomButton(!isAtBottom);
222
+ const scrollingUp = scrollTop < lastScrollTopRef.current;
223
+ lastScrollTopRef.current = scrollTop;
224
+ if (isAtBottom) setAutoScrollEnabled(true);
225
+ else if (scrollingUp) setAutoScrollEnabled(false);
220
226
  }
221
227
  }, []);
222
228
  const handleScrollToBottom = (0, external_react_namespaceObject.useCallback)(()=>{
@@ -226,13 +232,15 @@ function usePlaygroundState(playgroundSDK, storage, contextProvider, targetName)
226
232
  behavior: 'smooth'
227
233
  });
228
234
  setShowScrollToBottomButton(false);
235
+ setAutoScrollEnabled(true);
229
236
  }
230
237
  }, []);
231
238
  (0, external_react_namespaceObject.useEffect)(()=>{
232
- if (infoList.length > 0) scrollToBottom();
239
+ if (infoList.length > 0 && autoScrollEnabled) scrollToBottom();
233
240
  }, [
234
241
  infoList,
235
- scrollToBottom
242
+ scrollToBottom,
243
+ autoScrollEnabled
236
244
  ]);
237
245
  (0, external_react_namespaceObject.useEffect)(()=>{
238
246
  const container = infoListRef.current;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/visualizer",
3
- "version": "1.4.8",
3
+ "version": "1.4.9",
4
4
  "repository": "https://github.com/web-infra-dev/midscene",
5
5
  "homepage": "https://midscenejs.com/",
6
6
  "types": "./dist/types/index.d.ts",
@@ -60,10 +60,10 @@
60
60
  "antd": "^5.21.6",
61
61
  "buffer": "6.0.3",
62
62
  "dayjs": "^1.11.11",
63
- "@midscene/shared": "1.4.8",
64
- "@midscene/web": "1.4.8",
65
- "@midscene/core": "1.4.8",
66
- "@midscene/playground": "1.4.8"
63
+ "@midscene/core": "1.4.9",
64
+ "@midscene/playground": "1.4.9",
65
+ "@midscene/shared": "1.4.9",
66
+ "@midscene/web": "1.4.9"
67
67
  },
68
68
  "license": "MIT",
69
69
  "scripts": {