diff --git a/dist/index.js b/dist/index.js index 85e6d44..0f54871 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7,6 +7,7 @@ var QRReader = class _QRReader extends HTMLElement { #barcodeDetector = new BarcodeDetector({ formats: ["qr_code"] }); #timer = 0; + #initialized = false; video = null; canvas = null; constructor() { @@ -28,7 +29,10 @@ // LifeCycle Callbacks // connectedCallback() { - this.initialize(); + if (!this.#initialized) { + this.initialize(); + this.#initialized = true; + } } attributeChangedCallback(attributeName, oldValue, newValue) { const fn = this[attributeName + "Changed"]; diff --git a/qr-reader.js b/qr-reader.js index 1c01497..7629e13 100644 --- a/qr-reader.js +++ b/qr-reader.js @@ -4,6 +4,7 @@ const { } = window export default class QRReader extends HTMLElement { + #initialized = false #barcodeDetector = new BarcodeDetector({ formats: ['qr_code'] }) #timer = 0 video = null @@ -34,7 +35,10 @@ export default class QRReader extends HTMLElement { // LifeCycle Callbacks // connectedCallback () { - this.initialize() + if (!this.#initialized) { + this.initialize() + this.#initialized = true + } } attributeChangedCallback (attributeName, oldValue, newValue) {