pads/sliders: avoid duplicate touch events

This commit is contained in:
bordun 2021-02-07 14:34:05 +01:00
parent 9cb50eee57
commit 0193234175
6 changed files with 17 additions and 2 deletions

View file

@ -3,7 +3,9 @@
## 1.8.6
- bug fixes
- range: per-fader touch event not emitted properly
- range: per-fader touch event not emitted properly
- rgb: fix `spring` property
- rgb: touch event not emitted
## 1.8.5

View file

@ -1,5 +1,7 @@
module.exports = (self, options)=>{
if (self.parent.preventChildrenTouchState) return
self.touched = 0
self.setValueTouchedQueue = undefined

View file

@ -53,6 +53,7 @@ module.exports = class MultiXy extends Pad {
this.labels = Array.isArray(this.getProp('points'))
this.pointSize = parseInt(this.getProp('pointSize'))
this.preventChildrenTouchState = true
this.pads = []
for (let i = 0; i < this.npoints; i++) {

View file

@ -2,7 +2,8 @@ var Widget = require('../common/widget'),
Xy = require('./xy'),
Fader = require('../sliders/fader'),
{clip, mapToScale, hsbToRgb, rgbToHsb} = require('../utils'),
html = require('nanohtml')
html = require('nanohtml'),
touchstate = require('../mixins/touch_state')
var faderDefaults = Fader.defaults()._props(),
xyDefaults = Xy.defaults()._props()
@ -39,6 +40,8 @@ module.exports = class Rgb extends Widget {
this.container.classList.toggle('contains-alpha', this.getProp('alpha'))
this.preventChildrenTouchState = true
this.pad = new Xy({props:{
...xyDefaults,
type: 'xy',
@ -103,6 +106,9 @@ module.exports = class Rgb extends Widget {
initValue[3] = this.getProp('rangeAlpha').min
}
touchstate(this, {element: this.widget, multitouch: true, ignoreCustomBindings: true})
if (this.getProp('spring')) {
this.on('dragend', (e)=>{

View file

@ -46,6 +46,8 @@ module.exports = class Xy extends Pad {
super(options)
this.preventChildrenTouchState = true
this.faders = {
x: new Fader({props:{
...faderDefaults,

View file

@ -49,6 +49,8 @@ class Range extends Fader {
<canvas></canvas>
`})
this.preventChildrenTouchState = true
this.faders = [
new SubFader({props:{
...faderDefaults,