Skip to content

Commit 1f78ed6

Browse files
authored
Merge pull request #28 from developmentseed/fix/slider-loading-state
Fix react slider loading
2 parents 3694385 + f964892 commit 1f78ed6

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

web-vite/src/app/cartoslider.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,33 @@ interface CartoSliderProps {
1010

1111
export function CartoSlider(props: CartoSliderProps) {
1212
const { isLoading, timestamps, dispatchAppState, currentTimestamp } = props;
13-
const lastTimestampIndex = timestamps?.length > 0 ? timestamps.length - 1 : 0;
14-
15-
const sliderOptions = isLoading
16-
? {
17-
max: 1,
18-
defaultValue: 1,
19-
}
20-
: {
21-
max: lastTimestampIndex,
22-
defaultValue: lastTimestampIndex,
23-
};
13+
const lastTimestampIndex =
14+
!isLoading && timestamps?.length > 0 ? timestamps.length - 1 : 10;
15+
const currentTimestampIndex = !isLoading
16+
? timestamps?.indexOf(currentTimestamp)
17+
: 10;
2418

2519
return (
2620
<section class="carto__slider--wrapper">
2721
<div class="carto__slider--heading">
28-
<h4>Changeset Animation</h4>
22+
<h4>Change Timeline</h4>
2923
</div>
3024
<div class="carto__slider">
3125
<div class="carto__slider--tools">
3226
<p>
33-
{currentTimestamp && new Date(currentTimestamp).toLocaleString()}
27+
{!isLoading && currentTimestamp
28+
? new Date(currentTimestamp).toLocaleString()
29+
: "Loading..."}
3430
</p>
3531
</div>
3632
<ReactSlider
3733
disabled={isLoading}
3834
className="carto--slider"
3935
markClassName="slider--mark"
4036
min={0}
41-
{...sliderOptions}
37+
max={lastTimestampIndex}
38+
defaultValue={lastTimestampIndex}
39+
value={currentTimestampIndex}
4240
thumbClassName="slider--thumb"
4341
trackClassName="slider--track"
4442
onChange={(value: number) => {

web-vite/src/index.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,14 @@ body {
8787
display: flex;
8888
flex-flow: column nowrap;
8989
padding: 1rem;
90+
padding-bottom: 2rem;
9091
}
9192
#map {
9293
min-height: 480px;
9394
max-height: 100%;
9495
}
9596
.maplibregl-popup-content {
97+
color: var(--base);
9698
padding: 1.25rem;
9799
border-radius: 0.25rem;
98100
box-shadow: 0 0 1rem 0 rgba(50,50,50,.125);
@@ -311,7 +313,7 @@ li.bar-chart__bar {
311313
.carto__slider--wrapper {
312314
display: flex;
313315
flex-flow: column nowrap;
314-
padding: 1rem;
316+
padding-bottom: 1rem;
315317
}
316318
.carto #map {
317319
flex: 8;

0 commit comments

Comments
 (0)