├── .babelrc ├── .editorconfig ├── .eslintrc.js ├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── dist ├── vue-quagga.js └── vue-quagga.js.map ├── examples └── src │ ├── App.vue │ ├── index.html │ └── index.js ├── package-lock.json ├── package.json ├── src ├── Scanner.vue └── index.js ├── webpack.dev.js ├── webpack.prod.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { "presets": ["@babel/preset-env"] } 2 | 3 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "extends": ["standard", 3 | 'plugin:vue/recommended', 4 | "plugin:prettier/recommended" 5 | ], 6 | "rules": { 7 | "prettier/prettier": [ 8 | "error", 9 | { 10 | "singleQuote": true, 11 | "trailingComma": "es5" 12 | } 13 | ] 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | npm-debug.log 4 | yarn-error.log 5 | 6 | # Editor directories and files 7 | .idea 8 | *.suo 9 | *.ntvs* 10 | *.njsproj 11 | *.sln 12 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | examples 2 | .babelrc 3 | .gitignore 4 | .editorconfig 5 | .eslintrc.js 6 | .idea 7 | webpack.dev.js 8 | webpack.prod.js 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 tanasinn 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](https://cdn-images-1.medium.com/max/1600/1*u5EN9YE4S2R7QbJ-rHOZpg.gif) 2 | 3 | # vue-quaggajs 4 | 5 | [quaggajs](https://serratus.github.io/quaggaJS/) 's wrapper for Vue.js 6 | 7 | # Installtion 8 | 9 | ## npm 10 | 11 | ``` bash 12 | npm i vue-quaggajs 13 | ``` 14 | 15 | # Basic Example 16 | 17 | ``` 18 | 23 | 24 | 50 | ``` 51 | 52 | 53 | # Usage 54 | 55 | ### `onDetected` : function(result) 56 | 57 | Reference: [Quagga.onDetected(callback)](https://github.com/serratus/quaggaJS#quaggaondetectedcallback) 58 | 59 | default function: 60 | 61 | ```js 62 | function (result) { 63 | console.log('detected: ', result); 64 | } 65 | ``` 66 | 67 | ### `onProcessed` : function(result) 68 | 69 | Reference: [Quagga.onProcessed(callback)](https://github.com/serratus/quaggaJS#quaggaonprocessedcallback) 70 | 71 | default function: 72 | 73 | ```js 74 | function (result) { 75 | let drawingCtx = Quagga.canvas.ctx.overlay, 76 | drawingCanvas = Quagga.canvas.dom.overlay; 77 | 78 | if (result) { 79 | if (result.boxes) { 80 | drawingCtx.clearRect(0, 0, parseInt(drawingCanvas.getAttribute("width")), parseInt(drawingCanvas.getAttribute("height"))); 81 | result.boxes.filter(function (box) { 82 | return box !== result.box; 83 | }).forEach(function (box) { 84 | Quagga.ImageDebug.drawPath(box, {x: 0, y: 1}, drawingCtx, {color: "green", lineWidth: 2}); 85 | }); 86 | } 87 | if (result.box) { 88 | Quagga.ImageDebug.drawPath(result.box, {x: 0, y: 1}, drawingCtx, {color: "#00F", lineWidth: 2}); 89 | } 90 | 91 | if (result.codeResult && result.codeResult.code) { 92 | Quagga.ImageDebug.drawPath(result.line, {x: 'x', y: 'y'}, drawingCtx, {color: 'red', lineWidth: 3}); 93 | } 94 | } 95 | }, 96 | ``` 97 | 98 | ### readerTypes: String[] 99 | 100 | Set reading barcode type. 101 | 102 | Reference: [https://github.com/serratus/quaggaJS#decoder](https://github.com/serratus/quaggaJS#decoder) 103 | 104 | default: `['code_128_reader']` 105 | 106 | ### readerSize: Object {width: Number, height: Number} 107 | 108 | Set reader size. it affects