sliders/pads: apply spring property dynamically

This commit is contained in:
bordun 2021-03-19 18:51:41 +01:00
parent 947d554d62
commit 17c76ac3fc
6 changed files with 33 additions and 2 deletions

View file

@ -5,6 +5,7 @@
- bug fixes:
- project tree: filter input position issue when scrolling
- sliders/pads: apply `spring` property dynamically
- project tree
- select range of contiguous widgets with shift + click

View file

@ -118,6 +118,7 @@ module.exports = class MultiXy extends Pad {
this.trigger('touch', {stopPropagation: true, touch: [parseInt(id), 1]})
this.pads[id].trigger('draginit', e)
this.pads[id].touched = 1
if (this.getProp('ephemeral')) this.batchDraw()
@ -141,6 +142,7 @@ module.exports = class MultiXy extends Pad {
e.stopPropagation = true
this.pads[i].touched = 0
this.pads[i].trigger('dragend', e)
this.trigger('touch', {stopPropagation: true, touch: [parseInt(this.touchMap[e.pointerId]), 0]})
@ -288,7 +290,13 @@ module.exports = class MultiXy extends Pad {
w.onPropChanged(propName)
}
return
case 'spring':
for (var w of this.pads) {
w.cachedProps[propName] = this.getProp(propName)
w.onPropChanged(propName, options)
}
this.batchDraw()
return
}
}

View file

@ -28,6 +28,8 @@ class Pad extends Canvas {
}
Pad.dynamicProps = Pad.prototype.constructor.dynamicProps.filter(n => n !== 'decimals')
Pad.dynamicProps = Pad.prototype.constructor.dynamicProps.filter(n => n !== 'decimals').concat([
'spring'
])
module.exports = Pad

View file

@ -281,6 +281,21 @@ module.exports = class Xy extends Pad {
}
onPropChanged(propName, options, oldPropValue) {
if (super.onPropChanged(...arguments)) return true
switch (propName) {
case 'spring':
if (this.getProp('spring') && !this.touched) this.setValue([this.faders.x.getSpringValue(),this.faders.y.getSpringValue()], {...options})
return
}
}
onRemove() {
this.faders.x.onRemove()

View file

@ -152,6 +152,7 @@ class Range extends Fader {
e.stopPropagation = true
this.faders[id].trigger('draginit', e)
this.faders[i].touched = 1
}
@ -177,6 +178,7 @@ class Range extends Fader {
if (!i) return
e.stopPropagation = true
this.faders[i].touched = 0
this.faders[i].trigger('dragend', e)

View file

@ -232,6 +232,9 @@ class Slider extends Canvas {
case 'steps':
this.setSteps()
return
case 'spring':
if (this.getProp('spring') && !this.touched) this.setValue(this.getSpringValue(), {...options})
return
}