From e481198cd044c90638d96ba1b59cdd9c7526574f Mon Sep 17 00:00:00 2001 From: IvankoRambo Date: Wed, 20 May 2020 21:01:54 +0300 Subject: [PATCH] Added callback function support on QR image onload event --- README.md | 12 +++++++++++- index.html | 6 +++++- qrcode.js | 14 +++++++++----- qrcode.min.js | 2 +- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5e2d2dc..0f4ce27 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,17 @@ var qrcode = new QRCode(document.getElementById("qrcode"), { height: 128, colorDark : "#000000", colorLight : "#ffffff", - correctLevel : QRCode.CorrectLevel.H + correctLevel : QRCode.CorrectLevel.H, + /** + * Fired when QR image element is loaded + * @param {HTMLElement} QR image DOM element + * @param {string} text to generate QR-code image + * @return {void} + */ + callback: function (image, text) { + console.log('text QR code was created from', text); + console.log('loaded image DOM element', image); + } }); ``` diff --git a/index.html b/index.html index fc16f3d..a344715 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,11 @@