UNPKG

@scandit/web-datacapture-barcode

Version:

Scandit Data Capture SDK for the Web

1 lines 2.38 kB
import"./BarcodeArAnnotation.js";import{updatePosition as e}from"./private/updatePosition.js";import{BarcodeArInfoAnnotation as t}from"./BarcodeArInfoAnnotation.js";import"./private/BarcodeArAnnotationVariation.js";import{Logger as n,ScanditHTMLElement as r}from"@scandit/web-datacapture-core";import{defineCustomElements as i}from"@scandit/web-datacapture-core/build/js/private/utils/defineCustomElements.js";var a=class a extends r{constructor(...e){super(...e),this.closeUp=null,this.farAway=null,this._annotationVariation=1}static register(){i({[a.tag]:a})}static create(e,r,i){let o=document.createElement(a.tag);return o._barcode=e,o.closeUp=r,o.farAway=i,r instanceof t||(n.warn(`Only BarcodeArInfoAnnotation is supported at the moment. The close up annotation will be ignored.`),o.closeUp=null),i instanceof t||(n.warn(`Only BarcodeArInfoAnnotation is supported at the moment. The far away annotation will be ignored.`),o.farAway=null),o.closeUp&&(o.closeUp.hidden=!0),o.farAway&&(o.farAway.hidden=!0),o}get currentAnnotation(){return this._annotationVariation===2?this.farAway:this.closeUp}get annotationTrigger(){var e;return((e=this.currentAnnotation)==null?void 0:e.annotationTrigger)??`highlightTapAndBarcodeScan`}set annotationTrigger(e){this.closeUp&&(this.closeUp.annotationTrigger=e),this.farAway&&(this.farAway.annotationTrigger=e)}set anchor(e){this.closeUp.anchor!==void 0&&(this.closeUp.anchor=e),this.farAway.anchor!==void 0&&(this.farAway.anchor=e)}get anchor(){return this.currentAnnotation.anchor??void 0}get barcode(){return this._barcode}updatePosition(t,n,r){this.updateAnnotationVisibility(),e(this,t,n)}get annotationVariation(){return this._annotationVariation}set annotationVariation(e){e!==this._annotationVariation&&(this._annotationVariation=e,this.updateAnnotationVisibility())}updateAnnotationVisibility(){let e=this._annotationVariation===2,t=!e;this.closeUp&&(this.closeUp.hidden=e),this.farAway&&(this.farAway.hidden=t)}static get threshold(){return a._threshold}static set threshold(e){a._threshold=e}connectedCallback(){this.closeUp&&this.append(this.closeUp),this.farAway&&this.append(this.farAway),this.updateAnnotationVisibility()}disconnectedCallback(){this.closeUp&&this.closeUp.remove(),this.farAway&&this.farAway.remove()}};a.tag=`scandit-barcode-ar-responsive-annotation`,a._threshold=.1;export{a as BarcodeArResponsiveAnnotation};