Kill the QRcode scanner when exiting the view
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from 'svelte';
|
import { onMount, onDestroy } from 'svelte';
|
||||||
import {
|
import {
|
||||||
Html5QrcodeScanner,
|
Html5QrcodeScanner,
|
||||||
type Html5QrcodeResult,
|
type Html5QrcodeResult,
|
||||||
@@ -37,6 +37,12 @@
|
|||||||
);
|
);
|
||||||
scanner.render(onScanSuccess, onScanFailure);
|
scanner.render(onScanSuccess, onScanFailure);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onDestroy(() => {
|
||||||
|
if (scanner) {
|
||||||
|
scanner.clear().catch(() => {});
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="qr-scanner" class="w-full h-full max-w-none overflow-hidden rounded-sm"></div>
|
<div id="qr-scanner" class="w-full h-full max-w-none overflow-hidden rounded-sm"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user