Skip to content

Commit

Permalink
Refactor example for CodePen
Browse files Browse the repository at this point in the history
  • Loading branch information
undecaf committed Jan 12, 2022
1 parent f78cefb commit 5fd0459
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions docs/example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ <h5>Image source</h5>

<input id="fileInput" type="file" style="display: none;" accept="image/*">

<input id="imgUrl" type="url" placeholder="Image URL" required>
<input id="imgUrl" type="url" placeholder="Paste an image URL then click outside" required>
<button id="imgBtn">Image file</button>
<button id="videoBtn">Camera</button>

Expand Down Expand Up @@ -117,13 +117,15 @@ <h5>Result</h5>
.querySelectorAll('[id]')
.forEach(element => el[element.id] = element)

const ctx = canvas.getContext('2d')

let timeoutId = null;


function detect(source) {
canvas.width = source.naturalWidth || source.videoWidth || source.width
const
canvas = el.canvas,
ctx = canvas.getContext('2d');

canvas.width = source.naturalWidth || source.videoWidth || source.width
canvas.height = source.naturalHeight || source.videoHeight || source.height

if (canvas.height && canvas.width) {
Expand Down

0 comments on commit 5fd0459

Please sign in to comment.