FIX: Demo animation
This commit is contained in:
@@ -32,7 +32,7 @@ import LogoMidi from '@/assets/logos/logoMidi.svg'
|
|||||||
import DeviceBar from '@/components/device/DeviceBar.vue'
|
import DeviceBar from '@/components/device/DeviceBar.vue'
|
||||||
import { useStore } from '@/store'
|
import { useStore } from '@/store'
|
||||||
import ScrambleText from '@/components/effects/ScrambleText.vue'
|
import ScrambleText from '@/components/effects/ScrambleText.vue'
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||||
|
|
||||||
const value = ref(69)
|
const value = ref(69)
|
||||||
|
|
||||||
@@ -40,19 +40,29 @@ const barValue = computed(() => value.value / 127 * 100)
|
|||||||
|
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
|
|
||||||
|
let anim = null
|
||||||
|
let step = null
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setInterval(() => {
|
console.log(step)
|
||||||
|
console.log(anim)
|
||||||
|
anim = setInterval(() => {
|
||||||
const target = Math.floor(Math.random() * 127)
|
const target = Math.floor(Math.random() * 127)
|
||||||
const anim = setInterval(() => {
|
step = setInterval(() => {
|
||||||
const intVal = Math.floor(value.value)
|
const intVal = Math.floor(value.value)
|
||||||
if (intVal < target) {
|
if (intVal < target) {
|
||||||
value.value = intVal + 1
|
value.value = intVal + 1
|
||||||
} else if (intVal > target) {
|
} else if (intVal > target) {
|
||||||
value.value = intVal - 1
|
value.value = intVal - 1
|
||||||
} else {
|
} else {
|
||||||
clearInterval(anim)
|
clearInterval(step)
|
||||||
}
|
}
|
||||||
}, 20)
|
}, 20)
|
||||||
}, 2000)
|
}, 2000)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
clearInterval(anim)
|
||||||
|
clearInterval(step)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
Reference in New Issue
Block a user