1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-25 01:05:15 +03:00

Auto merged - #2543 at Sun, 01 Aug 2021 01:17:06 GMT

Adjust Modes Name CSS min-width
This commit is contained in:
J Blackman 2021-08-01 11:17:06 +10:00 committed by GitHub
commit 79f2c84c19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 11 deletions

View file

@ -73,7 +73,6 @@
background-color: #e4e4e4;
border-bottom: 5px solid white;
color: grey;
min-width: 140px;
}
.tab-auxiliary .mode .info .name {

View file

@ -274,20 +274,11 @@ PortHandler.selectPort = function(ports) {
PortHandler.setPortsInputWidth = function() {
function getWidthofText(text) {
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
context.font = getComputedStyle(document.body).font;
return Math.ceil(context.measureText(text).width);
}
function findMaxLengthOption(selectEl) {
let max = 0;
$(selectEl.options).each(function () {
const textSize = getWidthofText(this.textContent);
const textSize = getTextWidth(this.textContent);
if (textSize > max) {
max = textSize;
}

View file

@ -293,6 +293,9 @@ TABS.auxiliary.initialize = function (callback) {
}
}
const length = Math.max(...(FC.AUX_CONFIG.map(el => el.length)));
$('.tab-auxiliary .mode .info').css('min-width', `${Math.round(length * getTextWidth('A'))}px`);
$('a.addRange').click(function () {
const modeElement = $(this).data('modeElement');
// auto select AUTO option; default to 'OR' logic

View file

@ -85,9 +85,19 @@ export function getMixerImageSrc(mixerIndex, reverseMotorDir, apiVersion)
return `./resources/motor_order/${mixerList[mixerIndex - 1].image}${reverse}.svg`;
}
export function getTextWidth(text) {
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
context.font = getComputedStyle(document.body).font;
return Math.ceil(context.measureText(text).width);
}
// TODO: these are temp binding while transition to module happens
window.degToRad = degToRad;
window.bytesToSize = bytesToSize;
window.checkChromeRuntimeError = checkChromeRuntimeError;
window.generateVirtualApiVersions = generateVirtualApiVersions;
window.getMixerImageSrc = getMixerImageSrc;
window.getTextWidth = getTextWidth;