knob: sensitivity and ctrl+drag preserve circular mode behavior

knob: `snap` mode now works like `circular` mode except for the touch start event (value can't jump from start to end anymore)
This commit is contained in:
bordun 2022-07-04 10:35:34 +02:00
parent 99a2652d09
commit fb621a6f9c
2 changed files with 7 additions and 12 deletions

View file

@ -5,6 +5,10 @@
- bug fixes
- editor: error when ctrl+clicking on a root's child
- widget
- knob: `sensitivity` and ctrl+drag preserve `circular` mode behavior
- knob: `snap` mode now works like `circular` mode except for the touch start event (value can't jump from start to end anymore)
## 1.16.6
- bug fixes

View file

@ -99,7 +99,7 @@ module.exports = class Knob extends Slider {
dragHandle(e) {
if ((this.getProp('mode') === 'vertical' && !e.traversing) || e.ctrlKey) {
if ((this.getProp('mode') === 'vertical' && !e.traversing)) {
// vertical
this.percent = -100 * (e.movementY / e.inertia * this.getProp('sensitivity')) / this.minDimension + this.percent
@ -108,17 +108,8 @@ module.exports = class Knob extends Slider {
var offsetX = this.lastOffsetX + e.movementX,
offsetY = this.lastOffsetY + e.movementY
if (e.traversing || this.getProp('mode') === 'circular') {
// circular
var diff = this.angleToPercent(this.coordsToAngle(offsetX, offsetY), true) - this.angleToPercent(this.coordsToAngle(this.lastOffsetX, this.lastOffsetY), true)
if (Math.abs(diff) < 50 && diff !== 0) this.percent += diff * 360 / this.maxAngle
} else {
// snap
this.percent = this.angleToPercent(this.coordsToAngle(offsetX, offsetY))
}
var diff = this.angleToPercent(this.coordsToAngle(offsetX, offsetY), true) - this.angleToPercent(this.coordsToAngle(this.lastOffsetX, this.lastOffsetY), true)
if (Math.abs(diff) < 50 && diff !== 0) this.percent += (diff * 360 / this.maxAngle) * this.getProp('sensitivity') / e.inertia
this.lastOffsetX = offsetX
this.lastOffsetY = offsetY