@scandit/web-datacapture-barcode
Version:
Scandit Data Capture SDK for the Web
1 lines • 2.3 kB
JavaScript
import {d}from'./chunk-XGPORK2H.js';import {a}from'./chunk-CYVVGAZ4.js';import {ScanditHTMLElement,Logger}from'@scandit/web-datacapture-core';import {defineCustomElements}from'@scandit/web-datacapture-core/build/js/private/utils/defineCustomElements.js';var o=class o extends ScanditHTMLElement{constructor(){super(...arguments);this.closeUp=null;this.farAway=null;this._annotationVariation=1;}static register(){defineCustomElements({[o.tag]:o});}static create(t,a,i){let n=document.createElement(o.tag);return n._barcode=t,n.closeUp=a,n.farAway=i,a instanceof d||(Logger.warn("Only BarcodeArInfoAnnotation is supported at the moment. The close up annotation will be ignored."),n.closeUp=null),i instanceof d||(Logger.warn("Only BarcodeArInfoAnnotation is supported at the moment. The far away annotation will be ignored."),n.farAway=null),n.closeUp&&(n.closeUp.hidden=true),n.farAway&&(n.farAway.hidden=true),n}get currentAnnotation(){return this._annotationVariation===2?this.farAway:this.closeUp}get annotationTrigger(){var t,a;return (a=(t=this.currentAnnotation)==null?void 0:t.annotationTrigger)!=null?a:"highlightTapAndBarcodeScan"}set annotationTrigger(t){this.closeUp&&(this.closeUp.annotationTrigger=t),this.farAway&&(this.farAway.annotationTrigger=t);}set anchor(t){this.closeUp.anchor!==void 0&&(this.closeUp.anchor=t),this.farAway.anchor!==void 0&&(this.farAway.anchor=t);}get anchor(){var t;return (t=this.currentAnnotation.anchor)!=null?t:void 0}get barcode(){return this._barcode}updatePosition(t,a$1,i){this.updateAnnotationVisibility(),a(this,t,a$1);}get annotationVariation(){return this._annotationVariation}set annotationVariation(t){t!==this._annotationVariation&&(this._annotationVariation=t,this.updateAnnotationVisibility());}updateAnnotationVisibility(){let t=this._annotationVariation===2,a=!t;this.closeUp&&(this.closeUp.hidden=t),this.farAway&&(this.farAway.hidden=a);}static get threshold(){return o._threshold}static set threshold(t){o._threshold=t;}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();}};o.tag="scandit-barcode-ar-responsive-annotation",o._threshold=.1;var c=o;export{c as a};