Skip to content

Commit

Permalink
Fix #28: Scanner.start: rename opts.monitor to opts.video.
Browse files Browse the repository at this point in the history
  • Loading branch information
schmich committed Jul 18, 2016
1 parent 042c4bd commit d793b40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Webcam-driven HTML5 QR code scanner.
<script type="text/javascript" src="dist/instascan.min.js"></script>
</head>
<body>
<video id="monitor"></video>
<video id="preview"></video>
<script type="text/javascript">
var scanner = new Instascan.Scanner({ monitor: document.getElementById('monitor') });
var scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
scanner.addListener('scan', function (content, image) {
console.log(content);
});
Expand All @@ -33,7 +33,7 @@ Webcam-driven HTML5 QR code scanner.
### `new Instascan.Scanner(opts)`

- Create a new scanner with options.
- `opts.monitor`: The HTML element to use for the camera's video preview. Must be a `<video>` element. By default, an invisible element will be created to host the video.
- `opts.video`: The HTML element to use for the camera's video preview. Must be a `<video>` element. By default, an invisible element will be created to host the video.
- `opts.mirror`: Whether to horizontally mirror the video preview. This is helpful when trying to scan a QR code with a user-facing camera. Default `true`.
- `opts.backgroundScan`: Whether to actively scan when the tab is not active. When `false`, this reduces CPU usage when the tab is not active. Default `false`.
- `opts.refractoryPeriod`: The period, in milliseconds, before the same QR code will be recognized in succession. Default `5000`.
Expand Down
10 changes: 5 additions & 5 deletions src/scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,16 @@ class Scanner extends EventEmitter {
}

_configureVideo(opts) {
if (opts.monitor) {
if (opts.monitor.tagName !== 'VIDEO') {
throw new Exception('Monitor must be a <video> element.');
if (opts.video) {
if (opts.video.tagName !== 'VIDEO') {
throw new Exception('Video must be a <video> element.');
}
}

var video = opts.monitor || document.createElement('video');
var video = opts.video || document.createElement('video');
video.setAttribute('autoplay', 'autoplay');

if (opts.mirror !== false && opts.monitor) {
if (opts.mirror !== false && opts.video) {
video.style.MozTransform = 'scaleX(-1)';
video.style.webkitTransform = 'scaleX(-1)';
video.style.OTransform = 'scaleX(-1)';
Expand Down

0 comments on commit d793b40

Please sign in to comment.