Fix several bugs related to the interaction between reactivity and imperative browser APIs
This commit is contained in:
@@ -32,8 +32,10 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
hid.addEventListener('disconnect', e => {
|
hid.addEventListener('disconnect', e => {
|
||||||
|
if (device === e.device) {
|
||||||
toast.info('Device disconnected')
|
toast.info('Device disconnected')
|
||||||
if (device === e.device) onchange(null)
|
onchange(null)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
async function renderPattern() {
|
async function renderPattern() {
|
||||||
if (imageBitmap === null) {
|
if (imageBitmap === null) {
|
||||||
onchange(null)
|
renderedBitmap = null
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,12 +71,15 @@
|
|||||||
|
|
||||||
const quantizedData = quantizer.reduce(ctx)
|
const quantizedData = quantizer.reduce(ctx)
|
||||||
renderedBitmap = quantizedData
|
renderedBitmap = quantizedData
|
||||||
onchange(quantizedData)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
renderPattern()
|
renderPattern()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
onchange(renderedBitmap)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class={cn('flex max-lg:flex-col gap-4', classNames)} {...restProps}>
|
<div class={cn('flex max-lg:flex-col gap-4', classNames)} {...restProps}>
|
||||||
|
|||||||
@@ -36,9 +36,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
|
const context2x = freshContext(canvas2xEl)
|
||||||
|
const context1x = freshContext(canvas1xEl)
|
||||||
|
|
||||||
if (bitmap === null) return
|
if (bitmap === null) return
|
||||||
drawQuantizedData(freshContext(canvas2xEl), bitmap)
|
|
||||||
drawQuantizedData(freshContext(canvas1xEl), bitmap)
|
drawQuantizedData(context2x, bitmap)
|
||||||
|
drawQuantizedData(context1x, bitmap)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user