sliders/xy: add spring option that makes the widget jump back to its initial value when released
This commit is contained in:
parent
06e803a1ee
commit
5c62d7ed55
4 changed files with 21 additions and 2 deletions
|
|
@ -20,6 +20,7 @@ module.exports.options = {
|
|||
separator2:'behaviour',
|
||||
|
||||
snap:false,
|
||||
spring:false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
|
|
@ -63,8 +64,10 @@ var Xy = module.exports.Xy = function(widgetData) {
|
|||
horizontal:true,
|
||||
height:'100%',
|
||||
width:'100%',
|
||||
value:widgetData.value.length==2?widgetData.value[0]:'',
|
||||
snap:widgetData.snap,
|
||||
range:widgetData.rangeX,
|
||||
origin:'auto',
|
||||
precision:widgetData.precision,
|
||||
logScale:widgetData.logScaleX
|
||||
}, true),
|
||||
|
|
@ -74,8 +77,10 @@ var Xy = module.exports.Xy = function(widgetData) {
|
|||
horizontal:false,
|
||||
height:'100%',
|
||||
width:'100%',
|
||||
value:widgetData.value.length==2?widgetData.value[1]:'',
|
||||
snap:widgetData.snap,
|
||||
range:widgetData.rangeY,
|
||||
origin:'auto',
|
||||
precision:widgetData.precision,
|
||||
logScale:widgetData.logScaleY
|
||||
|
||||
|
|
@ -107,6 +112,13 @@ var Xy = module.exports.Xy = function(widgetData) {
|
|||
this.dragHandle()
|
||||
})
|
||||
|
||||
if (this.widgetData.spring) {
|
||||
this.wrapper.on('dragend', ()=>{
|
||||
this.setValue([this.faders.x.springValue,this.faders.y.springValue],{sync:true,send:true,fromLocal:true})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.faders.x.input.change(()=>{
|
||||
var v = [this.faders.x.value, this.faders.y.value]
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@ var _sliders_base = module.exports = function(){
|
|||
this.originValue = this.widgetData.origin=='auto'?
|
||||
this.rangeValsMin:
|
||||
clip(this.widgetData.origin,[this.rangeValsMin,this.rangeValsMax])
|
||||
|
||||
|
||||
this.springValue = this.widgetData.value || this.originValue
|
||||
|
||||
this.widget.on('fake-right-click',function(e){
|
||||
if (!EDITING) {
|
||||
|
|
@ -60,6 +59,12 @@ var _sliders_base = module.exports = function(){
|
|||
this.canvas.on('draginit',this.draginitHandleProxy.bind(this))
|
||||
this.canvas.on('drag',this.dragHandleProxy.bind(this))
|
||||
|
||||
if (this.widgetData.spring) {
|
||||
this.canvas.on('dragend', ()=>{
|
||||
this.setValue(this.springValue,{sync:true,send:true,fromLocal:true})
|
||||
})
|
||||
}
|
||||
|
||||
this.input.change(function(){
|
||||
this.widget.setValue(parseFloat(this.input.val()),{sync:true,send:true})
|
||||
}.bind(this))
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ module.exports.options = {
|
|||
separator2:'behaviour',
|
||||
|
||||
snap:false,
|
||||
spring:false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ module.exports.options = {
|
|||
separator2:'behaviour',
|
||||
|
||||
snap:false,
|
||||
spring:false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue