Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/TempoLite.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2011,10 +2011,9 @@ watch(radio, (value: number | null) => {
}
const date = datesOfInterest.value[value] ?? singleDateSelected.value;
singleDateSelected.value = date;
setNearestDate(date.getTime());
if (sublocationRadio.value == 0 && value !== null) {
// run this manually as the watcher wouldn't trigger
goToLocationOfInterst(value, 0);
// nextTick so that singleDateSelected has time to update
nextTick(() => goToLocationOfInterst(value, 0));
} else {
sublocationRadio.value = 0;
}
Expand All @@ -2023,17 +2022,23 @@ watch(radio, (value: number | null) => {
watch(singleDateSelected, (value: Date) => {
// console.log(`singleDateSelected ${value}`);
const timestamp = value.getTime();
setNearestDate(timestamp);
// setNearestDate(timestamp);
if (radio.value !== null) {
const index = datesOfInterest.value.map(d => d.getTime()).indexOf(timestamp);
radio.value = index < 0 ? null : index;
const indices = datesOfInterest.value
.map((d, i) => (d.getTime() === timestamp ? i : -1))
.filter(i => i !== -1);

if (!indices.includes(radio.value)) {
radio.value = indices.length > 0 ? indices[0] : null;
}
}
imagePreload();
});

watch(sublocationRadio, (value: number | null) => {
if (value !== null && radio.value != null) {
goToLocationOfInterst(radio.value, value);
// nextTick so that singleDateSelected has time to update
nextTick(() => goToLocationOfInterst(radio.value!, value));
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/composables/useUniqueTimeSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const useUniqueTimeSelection = (timestamps: Ref<number[]>) => {

watch(singleDateSelected, (value) => {
setNearestDate(value.getTime());
});
}, { immediate: true });

return {
timeIndex,
Expand Down