Skip to content

Commit 32ac230

Browse files
committed
feat(globe): clear globe on type deselect, default full range, restart play
1 parent fc789e4 commit 32ac230

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

docs/globe.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ <h2 class="filter-title" id="timePeriodTitle">Time period</h2>
5959
<div class="range-fill" id="yearRangeFill"></div>
6060
</div>
6161
<input class="range-input range-input-min" type="range" id="yearStartSlider" min="1975" max="2025" value="1975" aria-label="Start year" />
62-
<input class="range-input range-input-max" type="range" id="yearEndSlider" min="1975" max="2025" value="1975" aria-label="End year" />
62+
<input class="range-input range-input-max" type="range" id="yearEndSlider" min="1975" max="2025" value="2025" aria-label="End year" />
6363
</div>
6464
</div>
6565
</div>

docs/js/scene2_globe.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const Scene2 = {
8787
countryCentroids: {},
8888
countryFeatures: {},
8989
countryNameToISO: new Map(),
90-
currentYearRange: [1975, 1975],
90+
currentYearRange: [1975, 2025],
9191
currentCountryData: {},
9292
debounceTimeout: null,
9393
disasterTypes: [],
@@ -267,9 +267,11 @@ const Scene2 = {
267267
},
268268

269269
selectType(type) {
270-
if (!type || type === this.selectedType) return;
270+
if (!type) return;
271271

272-
this.selectedType = type;
272+
// Toggle off when the already-active type is clicked: no type selected
273+
// leaves the globe empty (no markers, 0 events).
274+
this.selectedType = type === this.selectedType ? null : type;
273275
this.updateSelectedTypeButtons();
274276
this.updateEventCount();
275277
this.debounceUpdate();
@@ -734,16 +736,13 @@ const Scene2 = {
734736
this.playButton?.classList.add('playing');
735737
this.playButton?.setAttribute('aria-label', 'Pause timeline animation');
736738

737-
// Set start year to 1975 if not already
738-
const currentStart = this.currentYearRange[0];
739-
if (currentStart !== 1975) {
740-
this.currentYearRange = [1975, 1975];
741-
this.yearStartSlider.value = 1975;
742-
this.yearEndSlider.value = 1975;
743-
this.updateYearRangeUI();
744-
this.updateEventCount();
745-
this.updateVisualization();
746-
}
739+
// Always restart the sweep from 1975 so Play replays the full animation.
740+
this.currentYearRange = [1975, 1975];
741+
this.yearStartSlider.value = 1975;
742+
this.yearEndSlider.value = 1975;
743+
this.updateYearRangeUI();
744+
this.updateEventCount();
745+
this.updateVisualization();
747746

748747
// Use slower speed for bubble chart, normal speed for globe
749748
const speed = this.bubbleChartVisible ? this.animationSpeed * 2 : this.animationSpeed;

0 commit comments

Comments
 (0)