Skip to content

Commit

Permalink
feat: make canvas reactive with the prop changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dyaskur committed Jul 7, 2024
1 parent 4307f43 commit c250581
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-spin-the-wheel",
"version": "1.0.0",
"version": "1.0.1",
"type": "module",
"author": "Xiaolin Zhu",
"contributors": [
Expand Down Expand Up @@ -32,7 +32,7 @@
"build": "vue-tsc && vite build",
"generate:types": "vue-tsc --declaration --emitDeclarationOnly --outdir ./dist",
"preview": "vite preview",
"deploy": "vite --config vite.demo.config.ts build && gh-pages -d dist"
"deploy": "vite --config vite.demo.config.ts build && gh-pages -d dist --cname vue-spin-the-wheel.yaskur.com"
},
"files": [
"dist"
Expand Down
5 changes: 4 additions & 1 deletion src/components/SpinTheWheel/hooks/useCanvas.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ref, computed, onMounted} from 'vue'
import {ref, computed, onMounted, onUpdated} from 'vue'
import type {CanvasConfig, PrizeConfig, PropsType} from '../types'
import {getStrArray} from '../utils.ts'

Expand Down Expand Up @@ -82,6 +82,9 @@ export function useCanvas(props: PropsType) {
if (props.type === 'canvas') drawCanvas()
})

onUpdated(() => {
if (props.type === 'canvas') drawCanvas()
})
return {
wheelEl,
canvasConfig,
Expand Down

0 comments on commit c250581

Please sign in to comment.