mirror of
https://github.com/DavidHDev/vue-bits.git
synced 2026-04-22 09:54:39 -06:00
fix: Modify onMounted to use nextTick for DOM updates
Updated onMounted lifecycle hook to wait for DOM updates before initializing particles.
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, onUnmounted, watch, useTemplateRef } from 'vue';
|
import { ref, onMounted, onUnmounted, watch, useTemplateRef, nextTick } from 'vue';
|
||||||
import { Renderer, Camera, Geometry, Program, Mesh } from 'ogl';
|
import { Renderer, Camera, Geometry, Program, Mesh } from 'ogl';
|
||||||
|
|
||||||
interface ParticlesProps {
|
interface ParticlesProps {
|
||||||
@@ -296,7 +296,9 @@ const cleanup = () => {
|
|||||||
program = null;
|
program = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
// CHANGED onMounted
|
||||||
|
onMounted(async () => {
|
||||||
|
await nextTick(); // wait for Vue to flush its DOM updates first
|
||||||
initParticles();
|
initParticles();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user