sliders/pads: when receiving feedback while touched, the widget waits to be released before updating to the latest received value.
This commit is contained in:
parent
e42f14577d
commit
603e92938c
8 changed files with 56 additions and 34 deletions
|
|
@ -1,5 +1,12 @@
|
|||
# Changelog
|
||||
|
||||
## 0.20.4
|
||||
|
||||
- osc
|
||||
- messages received almost simultaneously are now bundled before being sent to the clients. This helps preserving their order.
|
||||
- widgets
|
||||
- sliders/pads: when receiving feedback while touched, the widget waits to be released before updating to the latest received value.
|
||||
|
||||
## 0.20.3
|
||||
|
||||
- bug fixes
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
module.exports = (self, element)=>{
|
||||
|
||||
self._touched = 0
|
||||
element.on('draginit',(e)=>{
|
||||
self._touched += 1
|
||||
if (self._touched == 1)
|
||||
self.sendValue({
|
||||
address:self.getProp('touchAddress'),
|
||||
v:1,
|
||||
split:false
|
||||
})
|
||||
})
|
||||
|
||||
element.on('dragend', (e, data, traversing)=>{
|
||||
if (self._touched == 1) {
|
||||
self._touched = 0
|
||||
self.sendValue({
|
||||
address:self.getProp('touchAddress'),
|
||||
v:0,
|
||||
split:false
|
||||
})
|
||||
} else if (self._touched > 1){
|
||||
self._touched -= 1
|
||||
if (traversing) self._touched = 1
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
41
src/browser/js/app/widgets/mixins/touch_state.js
Normal file
41
src/browser/js/app/widgets/mixins/touch_state.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
module.exports = (self, element)=>{
|
||||
|
||||
var sendTouchState = self.getProp('touchAddress') && self.getProp('touchAddress').length
|
||||
|
||||
self.touched = 0
|
||||
self.setValueTouchedQueue = undefined
|
||||
|
||||
element.on('draginit',(e)=>{
|
||||
self.touched += 1
|
||||
if (self.touched == 1 && sendTouchState)
|
||||
self.sendValue({
|
||||
address:self.getProp('touchAddress'),
|
||||
v:1,
|
||||
split:false
|
||||
})
|
||||
})
|
||||
|
||||
element.on('dragend', (e, data, traversing)=>{
|
||||
if (self.touched == 1) {
|
||||
self.touched = 0
|
||||
|
||||
if (self.setValueTouchedQueue !== undefined) {
|
||||
self.setValue(...self.setValueTouchedQueue)
|
||||
self.setValueTouchedQueue = undefined
|
||||
}
|
||||
|
||||
if (sendTouchState) {
|
||||
self.sendValue({
|
||||
address:self.getProp('touchAddress'),
|
||||
v:0,
|
||||
split:false
|
||||
})
|
||||
}
|
||||
|
||||
} else if (self.touched > 1){
|
||||
self.touched -= 1
|
||||
if (traversing) self.touched = 1
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
var _canvas_base = require('../common/_canvas_base'),
|
||||
osctouchstate = require('../mixins/osc_touch_state')
|
||||
touchstate = require('../mixins/touch_state')
|
||||
|
||||
module.exports = class _pads_base extends _canvas_base {
|
||||
|
||||
|
|
@ -20,8 +20,7 @@ module.exports = class _pads_base extends _canvas_base {
|
|||
this.pointSize = parseInt(this.getProp('pointSize'))
|
||||
this.widget[0].style.setProperty('--pointSize', this.pointSize + 'rem')
|
||||
|
||||
if (this.getProp('touchAddress') && this.getProp('touchAddress').length)
|
||||
osctouchstate(this, this.wrapper)
|
||||
touchstate(this, this.wrapper)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -218,6 +218,7 @@ module.exports = class MultiXy extends _pads_base {
|
|||
setValue(v, options={}) {
|
||||
|
||||
if (!v || !v.length || v.length!=this.npoints * 2) return
|
||||
if (this.touched && !options.dragged) return this.setValueTouchedQueue = arguments
|
||||
|
||||
for (var i=0;i<this.npoints;i++) {
|
||||
if (!options.dragged) {
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ module.exports = class Rgb extends _pads_base {
|
|||
setValue(v, options={}) {
|
||||
|
||||
if (!v || !v.length || v.length!=3) return
|
||||
if (this.touched && !options.dragged) return this.setValueTouchedQueue = arguments
|
||||
|
||||
for (let i in [0,1,2]) {
|
||||
v[i] = clip(v[i],[0,255])
|
||||
|
|
|
|||
|
|
@ -168,6 +168,7 @@ module.exports = class Xy extends _pads_base {
|
|||
setValue(v, options={}) {
|
||||
|
||||
if (!v || !v.length || v.length!=2) return
|
||||
if (this.touched && !options.dragged) return this.setValueTouchedQueue = arguments
|
||||
|
||||
if (!options.dragged) {
|
||||
this.faders.x.setValue(v[0], {sync: false, send:false, dragged:false})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var {clip, mapToScale} = require('../utils'),
|
||||
_canvas_base = require('../common/_canvas_base'),
|
||||
osctouchstate = require('../mixins/osc_touch_state'),
|
||||
touchstate = require('../mixins/touch_state'),
|
||||
doubletab = require('../mixins/double_tap'),
|
||||
Input = require('../inputs/input')
|
||||
|
||||
|
|
@ -60,8 +60,7 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
|
||||
}
|
||||
|
||||
if (this.getProp('touchAddress') && this.getProp('touchAddress').length)
|
||||
osctouchstate(this, this.wrapper)
|
||||
touchstate(this, this.wrapper)
|
||||
|
||||
this.wrapper.on('mousewheel',this.mousewheelHandleProxy.bind(this))
|
||||
this.wrapper.on('draginit',this.draginitHandleProxy.bind(this))
|
||||
|
|
@ -196,6 +195,7 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
setValue(v,options={}) {
|
||||
|
||||
if (typeof v != 'number') return
|
||||
if (this.touched && !options.dragged) return this.setValueTouchedQueue = arguments
|
||||
|
||||
var value = clip(v,[this.rangeValsMin,this.rangeValsMax])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue