Skip to content

Commit

Permalink
update sveltekit example
Browse files Browse the repository at this point in the history
  • Loading branch information
thebrandonlucas committed Mar 21, 2024
1 parent a13e3f6 commit 67b49c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
3 changes: 2 additions & 1 deletion examples/sveltekit/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.svelte-kit
.env
.env
.yarn/install-state.gz
11 changes: 3 additions & 8 deletions examples/sveltekit/src/components/QrCode/QrCode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,18 @@
export let pollCallback = () => {}; // FIXME: allow undefined without breaking TS
export let clazz = '';
defineCustomElements();
onMount(() => {
defineCustomElements();
const qr = document.getElementById('qr') as any;
if (qr) {
qr.addEventListener('codeRendered', () => {
qr.callback = pollCallback;
qr.animateQRCode('MaterializeIn');
});
qr.callback = pollCallback;
}
});
onDestroy(() => {
const qr = document.getElementById('qr') as any;
if (qr) {
qr.removeEventListener('codeRendered', () => {
qr.callback = undefined;
});
qr.callback = undefined;
}
});
</script>
Expand Down

0 comments on commit 67b49c5

Please sign in to comment.