quagga2
quagga2 copied to clipboard
Make canvas.drawingBuffer optional
As discussed in #140 the canvas.drawingBuffer seems not to be required during runtime, as least in cases where you only want to detect barcodes.
From a first look through the code there is no real need for this element, which currently has to be hidden via CSS. And it doesn't hurt if the element is removed from the DOM via JS after initialization.
Some proposed changes, which could work:
- use it ONLY if the element exists
- if it doesn't exist: ignore it and do NOT create it from within the library
- add the canvas manually in the examples
- add some documentation about its usage to the debug section
- document this possible BC break in the release
What do you think @ericblade ? Does that make sense? It somehow collides with what you wrote in #33 - in that discussion it sounds as if the element is required.
yeah, that actually sounds preferable. Make the user control it, instead of having people wondering why they have to apply a bunch of CSS to make drawing work.
I remember there's at least one or two references to the drawingBuffer where some properties are assigned to it (one of them was during window resize, i think) so those sections might need to be guarded to prevent assigning into an undefined...
i think this would replace #33, probably.
Hey @kevinpapst in more recent changes, some of the relevant code has been moved over to src/quagga/initCanvas.ts .
If you'd like to do a pull req on this, we should just need to make sure any accesses to canvas.overlay are properly guarded, update any samples in the repo, and make sure the documentation points out that if you want to draw on top of it, we'll provide the interface, if you provide the #drawingBuffer .
I am intending on doing a major version bump when #171 is merged, so it's a good time to get any interface changes in :)
I might get to doing this, if no one else does, sometime.