0.1.2 • Published 9 months ago

@diadal/barcode-scanner v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@diadal/barcode-scanner

A fast and efficient (QR) barcode scanner for Capacitor

Install

npm install @diadal/barcode-scanner
npx cap sync
import { BarcodeScanner } from '@diadal/barcode-scanner';


function Scaner() {

      window.document.body.classList.add('qrscanner');
      BarcodeScanner.startScan()
        .then((result: ScanResult) => {
          window.document.body.classList.remove('qrscanner');
          console.log('result222cc', result);
        })
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        .catch((error: any) => {
          window.document.body.classList.remove('qrscanner');
          console.log('error333', error);
        });
    }
.scanner-ui {
display: none;
}
.scanner-hide {
visibility: visible;
}

body.qrscanner {
background-color: transparent;
}
body.qrscanner .scanner-ui {
display: block;
}
body.qrscanner .scanner-hide {
visibility: hidden;
}

.ion-content {
--background: transparent;
}

ion-content {
--background: transparent;
}

Thansk To [https://github.com/capacitor-community/camera-preview

](camera-preview)

API

startScan(...)

startScan(data: CameraPreviewOptions | null) => Promise<ScanResult>
ParamType
dataCameraPreviewOptions | null

Returns: Promise<ScanResult>


Interfaces

ScanResult

PropType
hasContentboolean
codestring

CameraPreviewOptions

PropTypeDescription
widthnumberThe preview width in pixels, default window.screen.width (applicable to the android and ios platforms only)
heightnumberThe preview height in pixels, default window.screen.height (applicable to the android and ios platforms only)
xnumberThe x origin, default 0 (applicable to the android and ios platforms only)
ynumberThe y origin, default 0 (applicable to the android and ios platforms only)
paddingBottomnumberThe preview bottom padding in pixes. Useful to keep the appropriate preview sizes when orientation changes (applicable to the android and ios platforms only)
rotateWhenOrientationChangedbooleanRotate preview when orientation changes (applicable to the ios platforms only; default value is true)
positionstringChoose the camera to use 'front' or 'rear', default 'front'
enableHighResolutionbooleanDefaults to false - iOS only - Activate high resolution image capture so that output images are from the highest resolution possible on the device *

Type Aliases

CameraPosition

'rear' | 'front'

0.1.0

9 months ago

0.1.2

9 months ago

0.1.1

9 months ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago