Kill the QRcode scanner when exiting the view

This commit is contained in:
Roman Krček
2025-06-25 14:54:06 +02:00
parent c28c338de4
commit 6c2e80ecc1

View File

@@ -1,5 +1,5 @@
<script lang="ts">
import { onMount } from 'svelte';
import { onMount, onDestroy } from 'svelte';
import {
Html5QrcodeScanner,
type Html5QrcodeResult,
@@ -37,6 +37,12 @@
);
scanner.render(onScanSuccess, onScanFailure);
});
onDestroy(() => {
if (scanner) {
scanner.clear().catch(() => {});
}
});
</script>
<div id="qr-scanner" class="w-full h-full max-w-none overflow-hidden rounded-sm"></div>