sliders: make spring and default dynamic

This commit is contained in:
bordun 2019-06-26 09:22:24 +02:00
parent 6086802001
commit bee8b7d814
2 changed files with 14 additions and 6 deletions

View file

@ -4,6 +4,8 @@
- bug fixes
- launcher: spaces not properly escaped in quoted strings
- widgets
- sliders: `default` and `spring` properties are now dynamic
## 0.46.2

View file

@ -49,8 +49,6 @@ class Slider extends Canvas {
this.rangeValsMin:
clip(this.getProp('origin'), [this.rangeValsMin,this.rangeValsMax])
this.springValue = this.getProp('default') !== '' ? this.getProp('default') : this.originValue
if (this.getProp('doubleTap')) {
if (typeof this.getProp('doubleTap') === 'string' && this.getProp('doubleTap')[0] === '/') {
@ -62,7 +60,7 @@ class Slider extends Canvas {
} else {
doubletab(this.widget, ()=>{
this.setValue(this.springValue,{sync:true, send:true, fromLocal:true})
this.setValue(this.getSpringValue(),{sync:true, send:true, fromLocal:true})
})
}
@ -115,7 +113,7 @@ class Slider extends Canvas {
this.setSteps()
this.setValue(this.springValue)
this.setValue(this.getSpringValue())
}
@ -176,7 +174,7 @@ class Slider extends Canvas {
dragendHandle(e, data, traversing) {
if (this.getProp('spring')) {
this.setValue(this.springValue,{sync:true,send:true,fromLocal:true})
this.setValue(this.getSpringValue(),{sync:true,send:true,fromLocal:true})
}
}
@ -195,6 +193,12 @@ class Slider extends Canvas {
}
getSpringValue() {
return this.getProp('default') !== '' ? this.getProp('default') : this.originValue
}
percentToValue(percent) {
@ -297,7 +301,9 @@ class Slider extends Canvas {
Slider.dynamicProps = Slider.prototype.constructor.dynamicProps
.filter(n => n !== 'precision')
.concat([
'steps'
'steps',
'spring',
'default',
])
module.exports = Slider