Socket
Socket
Sign inDemoInstall

vue-cc-quaggajs

Package Overview
Dependencies
80
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vue-cc-quaggajs

A Vue.js component, accessing the device camera and allowing users to read barcodes, within the browser


Version published
Weekly downloads
31
decreased by-8.82%
Maintainers
1
Install size
13.8 MB
Created
Weekly downloads
 

Readme

Source

vue-cc-quaggajs

quaggajs 's wrapper for Vue.js

Installtion

npm

npm i vue-cc-quaggajs
<template>
  <quagga-scanner ref="scanner"></quagga-scanner>
</template>

<script>
import { QuaggaScanner } from 'vue-cc-quaggajs';

export default {
  //...
  components: {
    QuaggaScanner,
  },
  // ...
}
</script>

Usage

init : function()

function () {
  Quagga.init(this.quaggaState, function (err) {
    if (err) {
      return console.log(err);
    }

    Quagga.start();
  });

  Quagga.onDetected(this.onDetected ? this.onDetected : this._onDetected);
  Quagga.onProcessed(this.onProcessed ? this.onProcessed : this._onProcessed);
}

reInit : function()

function () {
  Quagga.stop();

  this.init();
}

getImage : function()

function () {
  const canvas = Quagga.canvas.dom.image;

  return canvas.toDataURL();
}

onDetected : function(result)

Reference: Quagga.onDetected(callback)

default function:

function (result) {
  console.log('detected: ', result);
}

onProcessed : function(result)

Reference: Quagga.onProcessed(callback)

default function:

function (result) {
  let drawingCtx = Quagga.canvas.ctx.overlay,
    drawingCanvas = Quagga.canvas.dom.overlay;

  if (result) {
    if (result.boxes) {
      drawingCtx.clearRect(0, 0, parseInt(drawingCanvas.getAttribute("width")), parseInt(drawingCanvas.getAttribute("height")));
      result.boxes.filter(function (box) {
        return box !== result.box;
      }).forEach(function (box) {
        Quagga.ImageDebug.drawPath(box, {x: 0, y: 1}, drawingCtx, {color: "green", lineWidth: 2});
      });
    }
    if (result.box) {
      Quagga.ImageDebug.drawPath(result.box, {x: 0, y: 1}, drawingCtx, {color: "#00F", lineWidth: 2});
    }

    if (result.codeResult && result.codeResult.code) {
      Quagga.ImageDebug.drawPath(result.line, {x: 'x', y: 'y'}, drawingCtx, {color: 'red', lineWidth: 3});
    }
  }
},

readerType: Array

Set reading barcode type.

Reference: https://github.com/serratus/quaggaJS#decoder

default: [{ format: 'code_128_reader', config: {} }]

readerSize: Object {width: Number, height: Number}

Set reader size. it affects size.

default:

{
  width: 640,
  height: 480,
}

Basic Example

<template>
  <div>
    <quagga-scanner :onDetected="logIt" :readerSize="readerSize" :readerType="'ean_reader'"></quagga-scanner>
  </div>
</template>

<script>
import { QuaggaScanner } from 'vue-cc-quaggajs'
export default {
  name: 'VueBarcodeTest',
  data () {
    return {
      readerSize: {
        width: 640,
        height: 480
      }
    }
  },
  components: {
    QuaggaScanner
  },
  methods: {
    logIt (data) {
      console.log('detected', data)
    }

  }
}
</script>

Keywords

FAQs

Last updated on 26 Feb 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc