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>

View file

@ -60,6 +60,7 @@
id="loop-animation"
class="btn btn--transparent btn--outline"
data-icon="loop"
@click="isLoopAnimationEnabled = !isLoopAnimationEnabled"
>
<span>Animation en boucle</span>
</button>
@ -91,7 +92,9 @@ const { file } = defineProps({
file: Object,
});
const { activeTab, currentFile, step } = storeToRefs(useVirtualSampleStore());
const { activeTab, currentFile, step, isLoopAnimationEnabled } = storeToRefs(
useVirtualSampleStore()
);
const { isCommentsOpen } = storeToRefs(useDialogStore());
// Variables