Skip to content

Commit e423b21

Browse files
committed
feat(packages/vue): add autostart properties
1 parent 47aa955 commit e423b21

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

examples/with-vue/src/App.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<Fireworks
99
ref="fw"
1010
v-if="mounted"
11+
:autostart="false"
1112
:options="options"
1213
:style="{
1314
top: 0,
@@ -21,7 +22,7 @@
2122
</template>
2223

2324
<script lang="ts" setup>
24-
import { onMounted, ref, watch } from 'vue'
25+
import { ref, watch } from 'vue'
2526
import { Fireworks } from '@fireworks-js/vue'
2627
import type { FireworksOptions } from '@fireworks-js/vue'
2728
@@ -36,10 +37,6 @@ async function startFireworks() {
3637
await fireworks?.waitStop()
3738
}
3839
39-
onMounted(() => {
40-
startFireworks()
41-
})
42-
4340
watch(fw, () => {
4441
if (fw.value) {
4542
startFireworks()

packages/vue/src/fireworks.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import type { FireworksOptions } from 'fireworks-js'
44
import { PropType, defineExpose, onMounted, onUnmounted, ref } from 'vue'
55
66
const props = defineProps({
7+
autostart: {
8+
type: Boolean,
9+
default: true
10+
},
711
options: {
812
type: Object as PropType<FireworksOptions>,
913
required: false
@@ -15,7 +19,9 @@ const container = ref<HTMLDivElement>()
1519
1620
onMounted(() => {
1721
fireworks.value = new Fireworks(container.value!, props.options)
18-
fireworks.value.start()
22+
if (props.autostart) {
23+
fireworks.value.start()
24+
}
1925
})
2026
2127
onUnmounted(() => {

0 commit comments

Comments
 (0)