Skip to content

Commit b58c282

Browse files
authored
docs: add API overview section
also remove null-check in track-prop code example. Since custom track functions are not called with null anymore.
1 parent 27193df commit b58c282

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

README.md

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ A Vue.js 2 component, accessing the device camera and allowing users to read QR
5656
* on iOS it **only** works with Safari. Chrome or Firefox for iOS are not supported (see [#29](../../issues/29))
5757
* more details on [Caniuse](https://caniuse.com/#feat=stream)
5858

59+
# API
60+
61+
| Prop | Valid Types |
62+
|-----------|-----------------------|
63+
| `:track` | `Boolean`, `Function` |
64+
| `:paused` | `Boolean` |
65+
| `:camera` | `Boolean`, `Object` |
66+
67+
| Event | Payload Type |
68+
|-----------|-------------------|
69+
| `@decode` | `String` |
70+
| `@detect` | `Promise<Object>` |
71+
| `@init` | `Promise<void>` |
72+
5973
# Usage
6074

6175
### `decode` event
@@ -168,26 +182,24 @@ Say you want to paint in a different color that better fits your overall page th
168182
```javascript
169183
methods: {
170184
repaintLocation (location, ctx) {
171-
if (location !== null) {
172-
const {
173-
topLeftCorner,
174-
topRightCorner,
175-
bottomLeftCorner,
176-
bottomRightCorner,
177-
} = location
178-
179-
ctx.strokeStyle = 'blue' // instead of red
180-
181-
ctx.beginPath()
182-
ctx.moveTo(topLeftCorner.x, topLeftCorner.y)
183-
ctx.lineTo(bottomLeftCorner.x, bottomLeftCorner.y)
184-
ctx.lineTo(bottomRightCorner.x, bottomRightCorner.y)
185-
ctx.lineTo(topRightCorner.x, topRightCorner.y)
186-
ctx.lineTo(topLeftCorner.x, topLeftCorner.y)
187-
ctx.closePath()
188-
189-
ctx.stroke()
190-
}
185+
const {
186+
topLeftCorner,
187+
topRightCorner,
188+
bottomLeftCorner,
189+
bottomRightCorner,
190+
} = location
191+
192+
ctx.strokeStyle = 'blue' // instead of red
193+
194+
ctx.beginPath()
195+
ctx.moveTo(topLeftCorner.x, topLeftCorner.y)
196+
ctx.lineTo(bottomLeftCorner.x, bottomLeftCorner.y)
197+
ctx.lineTo(bottomRightCorner.x, bottomRightCorner.y)
198+
ctx.lineTo(topRightCorner.x, topRightCorner.y)
199+
ctx.lineTo(topLeftCorner.x, topLeftCorner.y)
200+
ctx.closePath()
201+
202+
ctx.stroke()
191203
}
192204
}
193205
```

0 commit comments

Comments
 (0)