UNPKG

scandit-web-datacapture-barcode

Version:

Scandit Data Capture SDK for the Web

6 lines (3 loc) 1.63 kB
import { k } from './chunk-YU4ASL7B.js'; var t=class extends EventTarget{constructor(){super(...arguments);this.orientation="portrait-primary";this.landscapeOrientationMediaQuery=matchMedia("(orientation: landscape)");this.screenOrientationChangeListener=this.onScreenOrientationChange.bind(this);this.landscapeOrientationMediaQueryChangeListener=this.onLandscapeOrientationMediaQueryChange.bind(this);}connectedCallback(){this.isScreenOrientationApiSupported()?(screen.orientation.addEventListener("change",this.screenOrientationChangeListener),this.onScreenOrientationChange()):(this.landscapeOrientationMediaQuery.addEventListener("change",this.landscapeOrientationMediaQueryChangeListener),this.onLandscapeOrientationMediaQueryChange(new MediaQueryListEvent("change",{matches:this.landscapeOrientationMediaQuery.matches})));}disconnectedCallback(){this.isScreenOrientationApiSupported()?screen.orientation.removeEventListener("change",this.screenOrientationChangeListener):this.landscapeOrientationMediaQuery.removeEventListener("change",this.landscapeOrientationMediaQueryChangeListener);}isScreenOrientationApiSupported(){return typeof ScreenOrientation=="function"&&screen.orientation instanceof ScreenOrientation}dispatchOrientationChangeEvent(e){this.dispatchEvent(new CustomEvent(k,{detail:e}));}onScreenOrientationChange(){this.orientation=screen.orientation.type,this.dispatchOrientationChangeEvent(this.orientation);}onLandscapeOrientationMediaQueryChange(e){let i=e;this.orientation=i.matches?"landscape-primary":"portrait-primary",this.dispatchOrientationChangeEvent(this.orientation);}}; export { t as a };