UNPKG

@scandit/web-datacapture-barcode

Version:

Scandit Data Capture SDK for the Web

1 lines 1.49 kB
import{visualFeedbackErrorColorCssVariable as e,visualFeedbackSuccessColorCssVariable as t}from"./constants/cssVariables.js";import{sparkScanViewVisualFeedbackTag as n}from"./constants/tags.js";import{ScanditHTMLElement as r,css as i,defineCustomElements as a,safeAwaitAnimation as o}from"@scandit/web-datacapture-core/build/js/private/utils/index.js";var s=class s extends r{get styleElement(){return this._styleElement??=i`${n}{height:var(--dvh);left:0;opacity:0;pointer-events:none;position:absolute;top:0;user-select:none;width:var(--dvw)}${n}[success]{background:var(${t})}${n}[error]{background:var(${e})}`,this._styleElement}get success(){return this.hasAttribute(`success`)}set success(e){this.toggleAttribute(`error`,!e),this.toggleAttribute(`success`,e)}get error(){return this.hasAttribute(`error`)}set error(e){this.toggleAttribute(`error`,e),this.toggleAttribute(`success`,!e)}static create(){return a({[n]:s}),document.createElement(n)}async fadeIn(e,t){await o(this.animate([{opacity:`0`},{opacity:e}],{duration:t,easing:`linear`}))}async fadeOut(e,t){await o(this.animate([{opacity:e},{opacity:`0`}],{duration:t,easing:`linear`}))}async emitSuccessFeedback(){this.success=!0,await this.fadeIn(`1`,200),await this.fadeOut(`1`,0)}async emitErrorFeedback(){this.error=!0,await this.fadeIn(`1`,100),await this.fadeOut(`1`,100),await this.fadeIn(`0.5`,100),await this.fadeOut(`0.5`,0)}connectedCallback(){this.append(this.styleElement)}};export{s as SparkScanViewVisualFeedback};