#11 - add reset view on track change

This commit is contained in:
isUnknown 2024-12-17 12:06:06 +01:00
parent 2a743e6377
commit 677309be6b

View file

@ -35,22 +35,6 @@ const virtualSampleStore = useVirtualSampleStore();
const isHelperHidden = ref(localStorage.getItem("isHelperHidden"));
localStorage.setItem("isHelperHidden", true);
// Images preload
const imageUrls = computed(() => activeTrack.files.map((file) => file.url));
watch(
imageUrls,
() => {
preloadImages();
},
{ immediate: true }
);
function preloadImages() {
imageUrls.value.forEach((imageUrl) => {
const image = new Image();
image.src = imageUrl;
});
}
// Grab interaction
const yMax = computed(() => {
return parseInt(
@ -136,6 +120,11 @@ function handleVerticalRotation(event) {
}
}
function resetView() {
currentX.value = 0;
currentY.value = 0;
}
const throttledDragToRotate = throttle(dragToRotate, 50);
watch(isDragToRotateEnabled, (newValue) => {
@ -170,4 +159,21 @@ watch(isLoopAnimationEnabled, (newValue) => {
clearInterval(animationIntervalId);
}
});
// Images preload
const imageUrls = computed(() => activeTrack.files.map((file) => file.url));
watch(
imageUrls,
() => {
preloadImages();
resetView();
},
{ immediate: true }
);
function preloadImages() {
imageUrls.value.forEach((imageUrl) => {
const image = new Image();
image.src = imageUrl;
});
}
</script>