From 3798802115bd8e660fc509282ab455e836a84574 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 15 Nov 2016 15:21:33 +0100 Subject: [PATCH] knob: widget's content centering fixed --- CHANGELOG.md | 3 ++- src/browser/js/app/widgets/sliders/knob.js | 13 ++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 603dddde..4abeb15e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ - bug fixes - meters in faders were not always properly positionned - widgets - - knob: gauge's width is proportionnal to the knob's size in `compact` mode + - knob: gauge's width is proportionnal to the knob's size in `compact` mode; widget's content centering fixed; + ## 0.11.0 - bug fixes diff --git a/src/browser/js/app/widgets/sliders/knob.js b/src/browser/js/app/widgets/sliders/knob.js index 7f6eac7f..0a747da9 100644 --- a/src/browser/js/app/widgets/sliders/knob.js +++ b/src/browser/js/app/widgets/sliders/knob.js @@ -67,10 +67,9 @@ var Knob = module.exports.Knob = function(widgetData) { this.maxAngle = widgetData.angle // calculate lost height factor - var a = Math.sin((360 - this.maxAngle)), - h = a < 0 ? 1 - a : a - - this.lostHeightFactor = h / 4 + var a = this.maxAngle <= 180 ? + 1 : 1 - Math.sin((this.maxAngle - 180) / 2 * Math.PI / 180) + this.lostHeightFactor = a / 4 } @@ -137,10 +136,10 @@ Knob.prototype.resizeHandle = function() { _sliders_base.prototype.resizeHandle.call(this) this.minDimension = Math.min(this.width, this.height) this.gaugeWidth = this.minDimension / 8 - this.canvas[0].style.top = (this.minDimension / 2 - 15) * this.lostHeightFactor + 'px' if (this.widgetData.compact) { - this.input[0].style.marginTop = (this.minDimension / 2 - 15) * this.lostHeightFactor + 'px' - + this.canvas[0].style.top = this.input[0].style.marginTop = (this.minDimension) * this.lostHeightFactor - this.gaugeWidth / 4 + 'px' + } else { + this.canvas[0].style.top = Math.min((this.minDimension) * this.lostHeightFactor - this.margin * PXSCALE / 2, this.input.outerHeight() * .5) + 'px' } }