Skip to content

Commit 7ca9ec9

Browse files
committed
added auto scroll for snapshots
1 parent 12f942e commit 7ca9ec9

File tree

4 files changed

+12
-86
lines changed

4 files changed

+12
-86
lines changed

src/app/containers/ActionContainer.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable max-len */
2-
import React, { useEffect, useState } from 'react';
2+
import React, { useEffect, useState, useRef } from 'react';
33
import Action from '../components/Actions/Action';
44
import { emptySnapshots, changeView, changeSlider } from '../slices/mainSlice';
55
import { useDispatch, useSelector } from 'react-redux';
@@ -18,6 +18,7 @@ import RecordButton from '../components/Actions/RecordButton';
1818

1919
function ActionContainer(props: ActionContainerProps): JSX.Element {
2020
const [dropdownSelection, setDropdownSelection] = useState('TimeJump');
21+
const actionsEndRef = useRef(null as unknown as HTMLDivElement);
2122

2223
const dispatch = useDispatch();
2324
const { currentTab, tabs, port }: MainState = useSelector((state: RootState) => state.main);
@@ -34,6 +35,13 @@ function ActionContainer(props: ActionContainerProps): JSX.Element {
3435
// we create an array 'hierarchyArr' that will hold objects and numbers
3536
const hierarchyArr: (number | {})[] = [];
3637

38+
// Auto scroll when snapshots change
39+
useEffect(() => {
40+
if (actionsEndRef.current) {
41+
actionsEndRef.current.scrollIntoView({ behavior: 'smooth' });
42+
}
43+
}, [snapshots]); // Dependency on snapshots array
44+
3745
const displayArray = (obj: Obj): void => {
3846
if (
3947
obj.stateSnapshot.children.length > 0 && // if the 'stateSnapshot' has a non-empty 'children' array
@@ -209,6 +217,8 @@ function ActionContainer(props: ActionContainerProps): JSX.Element {
209217
Object.keys(routes).map((route, i) => (
210218
<RouteDescription key={`route${i}`} actions={routes[route]} />
211219
))}
220+
{/* Add ref for scrolling */}
221+
<div ref={actionsEndRef} />
212222
</div>
213223
</div>
214224
) : null}

src/app/styles/components/_componentMap.scss

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -131,45 +131,3 @@
131131
margin: 0;
132132
cursor: pointer;
133133
}
134-
135-
.control-range::-webkit-slider-thumb {
136-
appearance: none;
137-
width: 16px;
138-
height: 16px;
139-
border-radius: 50%;
140-
background: #14b8a6;
141-
cursor: pointer;
142-
border: none;
143-
transition: transform 0.2s ease;
144-
}
145-
146-
.control-range::-moz-range-thumb {
147-
width: 16px;
148-
height: 16px;
149-
border-radius: 50%;
150-
background: #14b8a6;
151-
cursor: pointer;
152-
border: none;
153-
transition: transform 0.2s ease;
154-
}
155-
156-
.control-range::-webkit-slider-thumb:hover {
157-
transform: scale(1.1);
158-
}
159-
160-
.control-range::-moz-range-thumb:hover {
161-
transform: scale(1.1);
162-
}
163-
164-
.control-range:disabled {
165-
opacity: 0.5;
166-
cursor: not-allowed;
167-
}
168-
169-
.control-range:disabled::-webkit-slider-thumb {
170-
cursor: not-allowed;
171-
}
172-
173-
.control-range:disabled::-moz-range-thumb {
174-
cursor: not-allowed;
175-
}

src/app/styles/layout/_stateContainer.scss

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -121,28 +121,7 @@
121121
}
122122

123123
.tooltip-data {
124-
border-left: 2px solid #0d9488; /* Teal border */
125-
}
126-
127-
.tooltip-content::-webkit-scrollbar {
128-
width: 4px;
129-
}
130-
131-
.tooltip-content::-webkit-scrollbar {
132-
width: 4px;
133-
}
134-
135-
.tooltip-content::-webkit-scrollbar-track {
136-
background: #f1f5f9;
137-
}
138-
139-
.tooltip-content::-webkit-scrollbar-thumb {
140-
background: #cbd5e1;
141-
border-radius: 4px;
142-
}
143-
144-
.tooltip-content::-webkit-scrollbar-thumb:hover {
145-
background: #94a3b8;
124+
border-left: 2px solid #0d9488;
146125
}
147126

148127
.tooltip-container {

src/app/styles/main.scss

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,6 @@ body {
1818
height: 100%;
1919
}
2020

21-
/* width */
22-
::-webkit-scrollbar {
23-
width: 5px;
24-
height: 8px;
25-
}
26-
27-
/* Track */
28-
::-webkit-scrollbar-track {
29-
background: none;
30-
}
31-
32-
/* Handle */
33-
::-webkit-scrollbar-thumb {
34-
background: rgb(67, 67, 71);
35-
}
36-
37-
/* Handle on hover */
38-
::-webkit-scrollbar-thumb:hover {
39-
background: rgb(97, 97, 97);
40-
}
41-
4221
// 1. Configuration and helpers
4322
@import 'abstracts/variablesLM';
4423

0 commit comments

Comments
 (0)