npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-zxing

v0.3.7

Published

[![NPM version](https://img.shields.io/npm/v/ngx-zxing.svg?&label=npm)](https://www.npmjs.com/package/ngx-zxing) [![Downloads](https://img.shields.io/npm/dm/ngx-zxing.svg)](https://npmjs.org/package/ngx-zxing) [![Dependency Status](https://david-dm.org

Downloads

38

Readme

NPM version Downloads Dependency Status Build Status Codacy Badge

Deprecated! Please install @zxing/ngx-scanner instead!

ngx-zxing

Angular QR-Code scanner component.

Features & Hints

  • Supports continuous scanning.
  • There is a delay of 1500ms after each successful scan, before a new QR-Code can be detected.
  • Supports iOS 11 (only in Safari via HTTPS).
  • Nice devs behind it. 🤓

Demo

Installation

To install this package, run:

yarn add @zxing/ngx-scanner@latest

Then import it into your Angular AppModule:

// Common imports
import { NgModule /* , ... */ } from '@angular/core';

// Import the package's module
import { NgxZxingModule } from 'ngx-zxing';

@NgModule({
    declarations: [ /* AppComponent ... */ ],
    imports: [
    
        // BrowserModule, 
        // ...
        
        // ZXing scanner module
        NgxZxingModule.forRoot(),
        
        // another imports...
    ],
    // ...
})
export class AppModule { }

Usage

Once the package is imported, you can use it in your Angular application:

<ngx-zxing
    [start]="camStarted"
    [device]="selectedDevice"
    [cssClass]="'small-video'"
    (camerasFound)="displayCameras($event)"
    (scanSuccess)="handleQrCodeResult($event)"
></ngx-zxing>
  • start can be used to start and stop the scanning (defaults to false)
  • device is the video-device used for scanning (use one of the devices emitted by onCamsFound)
  • cssClass this CSS-class name will be appended to the video-element e.g. for resizing it (see below)
  • camerasFound will emit an array of video-devices after view was initialized
  • scanSuccess will emit the result as string, after a valid QR-Code was scanned

Change the size of the preview-element

In your CSS, define an extra class and pass it to the component with the cssClass-parameter. CSS might look like this:

.small-video {
    max-height: 70vh;
    width: 100vw;
    object-fit: contain;
}

API

| Method | Parameters | Returns | Description | |---------------------|------------------------------------------------|----------------------------------|--------------------------------------------------------------| | changeDevice | device: MediaDeviceInfo | void | Allows you to properly change the scanner device on the fly. | | camerasFound | callback: (devices: MediaDeviceInfo[]) => {} | EventEmitter<MediaDeviceInfo > | Emits an event when cameras are found. | | camerasNotFound | callback: (): void => {} | EventEmitter<void> | Emits an event when cameras are not found. | | scanSuccess | callback: (result: string): void => {} | EventEmitter<string> | Emits an event when a scan is successful performed. | | scanFailure | callback: (): void => {} | EventEmitter<void> | Emits an event when a scan fails. | | scanError | callback: (error: any): void => {} | EventEmitter<any> | Emits an event when a scan throws an error. |

Performance

Copied from Instascan by Chris Schmich:

Many factors affect how quickly and reliably ZXing can detect QR codes.

If you control creation of the QR code, consider the following:

  • A larger physical code is better. A 2" square code is better than a 1" square code.
  • Flat, smooth, matte surfaces are better than curved, rough, glossy surfaces.
  • Include a sufficient quiet zone, the white border surrounding QR code. The quiet zone should be at least four times the width of an individual element in your QR code.
  • A simpler code is better. You can use this QR code generator to see how your input affects complexity.
  • For the same length, numeric content is simpler than ASCII content, which is simpler than Unicode content.
  • Shorter content is simpler. If you're encoding a URL, consider using a shortener such as goo.gl or bit.ly.

When scanning, consider the following:

  • QR code orientation doesn't matter.
  • Higher resolution video is better, but is more CPU intensive.
  • Direct, orthogonal scanning is better than scanning at an angle.
  • Blurry video greatly reduces scanner performance.
  • Auto-focus can cause lags in detection as the camera adjusts focus. Consider disabling it or using a fixed-focus camera with the subject positioned at the focal point.
  • Exposure adjustment on cameras can cause lags in detection. Consider disabling it or having a fixed white backdrop.

Limitations

  • The component relies on zxing-typescript which currently supports only QR-codes and no 1D-Barcode formats

Generator

Looking for a way to generate QR-Codes? Check-out ngx-kjua