This commit is contained in:
isUnknown 2024-12-16 16:27:21 +01:00
parent ab60a50437
commit 64af50816b
3 changed files with 30 additions and 2 deletions

View file

@ -9,6 +9,7 @@
import throttle from "lodash/throttle";
import { ref, computed, watch } from "vue";
import { useVirtualSampleStore } from "../../../stores/virtualSample";
import { storeToRefs } from "pinia";
const { activeTrack } = defineProps({
activeTrack: Object,
@ -111,4 +112,27 @@ watch(isDragToRotateEnabled, (newValue) => {
previousMouseYPos = undefined;
}
});
const { isLoopAnimationEnabled } = storeToRefs(useVirtualSampleStore());
function loopAnimation() {
rotateX("right");
if (currentX.value < xMax.value / 2) {
if (currentY.value < yMax.value - 1) currentY.value++;
} else {
if (currentY.value > 0) currentY.value--;
}
}
let animationIntervalId;
watch(isLoopAnimationEnabled, (newValue) => {
if (newValue) {
currentX.value = 0;
currentY.value = 0;
animationIntervalId = setInterval(loopAnimation, 300);
} else {
clearInterval(animationIntervalId);
}
});
</script>