From 6caa4d73c625eb402c8b609fd1aee4f0d2892258 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Thu, 17 Nov 2016 20:53:37 +0100 Subject: [PATCH] multixy: make non-snap mode work like other widget (you don't need to grab the handle directly); fix logscaleX|Y options --- CHANGELOG.md | 2 +- .../docs/user-guide/widgets-specifics/pads.md | 2 +- src/browser/js/app/widgets/pads/multixy.js | 20 ++++--------------- src/browser/scss/widgets/_pads.scss | 6 +----- 4 files changed, 7 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 459c7972..a5d4b64b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - widgets - fader: display pips to `compact` mode when `range` has multiple breakpoints - pads: display pips when `range` has multiple breakpoints - - multixy: style update (stroked dots, bold number font); `snap` option added. + - multixy: style update (stroked dots, bold number font); `snap` option added; points are automtically assigned to touches as they come; fix `logScale(X|Y)` options. ## 0.11.1 diff --git a/resources/docs/user-guide/widgets-specifics/pads.md b/resources/docs/user-guide/widgets-specifics/pads.md index f79dc050..535d2efb 100644 --- a/resources/docs/user-guide/widgets-specifics/pads.md +++ b/resources/docs/user-guide/widgets-specifics/pads.md @@ -105,7 +105,7 @@ Pads are multidimensional widgets that output multiple values. #### `snap` - type: `boolean` - default: `false` -- usage: by default, the points must be touched directy to be dragged; if set to `true`, touching anywhere on the widget's surface will assign the points to the touching fingers one by one. +- usage: by default, the points are dragged from their initial position; if set to `true`, touching anywhere on the widget's surface will make them snap to the touching coordinates (one per touch). ---- diff --git a/src/browser/js/app/widgets/pads/multixy.js b/src/browser/js/app/widgets/pads/multixy.js index 1fd773c5..784591df 100644 --- a/src/browser/js/app/widgets/pads/multixy.js +++ b/src/browser/js/app/widgets/pads/multixy.js @@ -10,7 +10,7 @@ module.exports.options = { separator1:'multi xy', points: 2, - pointSize: 15, + pointSize: 20, snap:false, separator2:'style', @@ -65,7 +65,8 @@ var MultiXy = module.exports.MultiXy = function(widgetData) { rangeX:widgetData.rangeX, rangeY:widgetData.rangeY, precision:widgetData.precision, - logScale:widgetData.logScaleY + logScaleX:widgetData.logScaleX, + logScaleY:widgetData.logScaleY }) this.pads[i].sendValue = ()=>{} this.pads[i].draw = ()=>{} @@ -74,7 +75,6 @@ var MultiXy = module.exports.MultiXy = function(widgetData) { this.handles[i] = $(`
${i}
`) this.wrapper.append(this.handles[i]) - if (this.widgetData.snap) { let pad = this.pads[i] pad.wrapper.on('draginit',(e)=>{ pad.widget.addClass('active') @@ -82,13 +82,9 @@ var MultiXy = module.exports.MultiXy = function(widgetData) { pad.wrapper.on('dragend',(e)=>{ pad.widget.removeClass('active') }) - - } } - if (this.widgetData.snap) { this.wrapper.addClass('snap') - } this.value = [] @@ -100,20 +96,12 @@ var MultiXy = module.exports.MultiXy = function(widgetData) { this.pads[i].widget.addClass('active') } this.pads[i].wrapper.trigger(e.type, [data, traversing]) - var v = this.pads[i].widget.getValue() - if (v < [this.value[i*2], this.value[i*2+1]] || v > [this.value[i*2], this.value[i*2+1]]) { - var n = this.widget.getValue() - n[i] = v - this.setValue(n, {sync:true,send:true, dragged:true}) - } }) }) this.wrapper.on('sync',(e)=>{ e.stopPropagation() - if (this.widgetData.snap) { - this.setValue(this.widget.getValue(), e.options) - } + this.setValue(this.widget.getValue(), e.options) }) this.widget.getValue = () => { diff --git a/src/browser/scss/widgets/_pads.scss b/src/browser/scss/widgets/_pads.scss index 9865ccdb..b8ace914 100644 --- a/src/browser/scss/widgets/_pads.scss +++ b/src/browser/scss/widgets/_pads.scss @@ -121,9 +121,8 @@ position: absolute; width:calc(100% - calc(var(--point-size) * 2 + 2rem)); height:calc(100% - calc(var(--point-size) * 2 + 2rem)); - pointer-events: none; &.active { - pointer-events: none!important; + pointer-events: none; } .wrapper { background: transparent; @@ -149,9 +148,6 @@ opacity: 0; z-index: 1; } - &.snap > .pad { - pointer-events: auto; - } } }