neocotic / qrious

Pure JavaScript library for QR code generation using canvas
https://neocotic.com/qrious
Other
1.55k stars 216 forks source link

Enable setting of multiple properties at once resulting in a single re-render #69

Closed neocotic closed 7 years ago

neocotic commented 7 years ago

Add a set method to allow multiple properties to be set at once, but with a single re-render. Given the following example:

const qr = new QRious({
  element: document.querySelector('canvas'),
  value: 'https://github.com/neocotic/qrious'
})

If you wanted to change the colours and value, QRious would re-render the QR code 3 times:

qr.background = '#ff0000'
qr.foreground = '#0000ff'
qr.value = 'QRious'

However, with this proposed change, these properties could be changed in a single call and result in a single re-render:

qr.set({
  background: '#ff0000',
  foreground: '#0000ff',
  value: 'QRious'
})

This should also be documented as well though while also explicitly mentioning that the QR code is re-rendered each time a property is changed.

neocotic commented 7 years ago

As a result of implementing this, QRious.DEFAULTS will be deprecated and scheduled for removal in the next major release (e.g 3.0.0).

neocotic commented 7 years ago

These changes will be included in the 2.3.0 release.