Skip to content

Commit

Permalink
feat: add play/pause/rewind controls to current layer slider
Browse files Browse the repository at this point in the history
  • Loading branch information
annehaley committed Oct 25, 2024
1 parent 5a08f7e commit 58f5d9a
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions web/src/components/OptionsDrawerContents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default {
const layerRange = ref<number[]>([]);
const colormapRange = ref<number[]>([]);
const applyToAll = ref<boolean>(true);
const ticker = ref();
const allowOpacityModification = computed(
() =>
Expand Down Expand Up @@ -220,6 +221,37 @@ export default {
opacity.value = 1;
}
function pause() {
clearInterval(ticker.value);
ticker.value = undefined;
}
function play() {
if (currentDataset.value?.map_layers) {
pause();
ticker.value = setInterval(() => {
if (
currentDataset.value?.map_layers &&
currentDatasetLayerIndex.value <
currentDataset.value.map_layers?.length - 1
) {
currentDatasetLayerIndex.value += 1;
} else {
pause();
}
}, 2000);
}
}
function rewind() {
pause();
ticker.value = setInterval(() => {
if (currentDatasetLayerIndex.value > 0) {
currentDatasetLayerIndex.value -= 1;
} else {
pause();
}
}, 2000);
}
watch(colormap, updateColormap);
watch(opacity, updateLayerOpacity);
Expand All @@ -245,6 +277,9 @@ export default {
getNetworkNodeName,
updateColormap,
resetNetwork,
play,
pause,
rewind,
};
},
};
Expand Down Expand Up @@ -283,8 +318,14 @@ export default {
dense
min="0"
step="1"
hide-details
:max="currentDataset?.map_layers.length - 1"
/>
<div style="width: 100%; text-align: center">
<v-btn @click="play" icon="mdi-play" variant="text" />
<v-btn @click="pause" icon="mdi-pause" variant="text" />
<v-btn @click="rewind" icon="mdi-rewind" variant="text" />
</div>
<v-card-subtitle class="wrap-subtitle">
Current layer name: {{ currentLayerName || "Untitled" }}
</v-card-subtitle>
Expand Down

0 comments on commit 58f5d9a

Please sign in to comment.