widget: when possible, init value as soon as possible to avoid undefined when an array is expected.
This commit is contained in:
parent
98a27de0df
commit
cac9fb7abc
8 changed files with 6 additions and 11 deletions
|
|
@ -201,6 +201,7 @@ class Widget extends EventEmitter {
|
|||
this.isValueChanging = false
|
||||
this.valueChangingTimeout = null
|
||||
this.valueChangingQueue = {}
|
||||
this.value = options.value
|
||||
|
||||
this.parsers = {}
|
||||
this.parsersLocalScope = options.locals || {}
|
||||
|
|
|
|||
|
|
@ -87,8 +87,6 @@ module.exports = class MultiXy extends Pad {
|
|||
|
||||
}
|
||||
|
||||
this.value = []
|
||||
|
||||
this.padsCoords = []
|
||||
this.touchMap = {}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class Pad extends Canvas {
|
|||
|
||||
constructor(options) {
|
||||
|
||||
super({...options, html: html`
|
||||
super({...options, value: [], html: html`
|
||||
<inner>
|
||||
<canvas></canvas>
|
||||
</inner>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ module.exports = class Rgb extends Widget {
|
|||
|
||||
constructor(options) {
|
||||
|
||||
super({...options, html: html`<inner></inner>`})
|
||||
super({...options, value: [], html: html`<inner></inner>`})
|
||||
|
||||
this.container.classList.toggle('contains-alpha', this.getProp('alpha'))
|
||||
|
||||
|
|
@ -125,8 +125,6 @@ module.exports = class Rgb extends Widget {
|
|||
}
|
||||
|
||||
|
||||
this.value = []
|
||||
|
||||
this.hsb = {h:0,s:0,b:0}
|
||||
|
||||
this.setValue(initValue)
|
||||
|
|
|
|||
|
|
@ -84,8 +84,6 @@ module.exports = class Xy extends Pad {
|
|||
e.stopPropagation = true
|
||||
})
|
||||
|
||||
this.value = []
|
||||
|
||||
touchstate(this, {element: this.canvas})
|
||||
|
||||
this.active = false
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class Range extends Fader {
|
|||
|
||||
options.multitouch = true
|
||||
|
||||
super({...options, html: html`
|
||||
super({...options, value: [], html: html`
|
||||
<canvas></canvas>
|
||||
`})
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ class Slider extends Canvas {
|
|||
|
||||
this.container.classList.add('design-' + this.getProp('design'))
|
||||
|
||||
this.value = undefined
|
||||
this.percent = 0
|
||||
|
||||
this.gaugePadding = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue