Skip to content

Commit

Permalink
Fix: Mixer preview images in web builds (#3567)
Browse files Browse the repository at this point in the history
* Fix: Mixer preview images in web builds

* Fix: Mixer preview images in web builds

* Refactor: Use function
  • Loading branch information
VitroidFPV authored Sep 5, 2023
1 parent c111129 commit 5a633c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/css/tabs/motors.less
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
border-bottom: 1px solid var(--subtleAccent);
}
.mixerPreview {
img {
svg {
width: 150px;
height: 150px;
margin-left: 15px;
Expand Down
16 changes: 11 additions & 5 deletions src/js/tabs/motors.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,17 @@ motors.initialize = async function (callback) {
lines.attr('d', graphHelpers.line);
}

function replace_mixer_preview(imgSrc) {
$.get(imgSrc, function(data) {
const svg = $(data).find('svg');
$('.mixerPreview').html(svg);
}, 'xml');
}

function update_model(mixer) {
const imgSrc = getMixerImageSrc(mixer, FC.MIXER_CONFIG.reverseMotorDir);
$('.mixerPreview img').attr('src', imgSrc);

replace_mixer_preview(imgSrc);

const motorOutputReorderConfig = new MotorOutputReorderConfig(100);
const domMotorOutputReorderDialogOpen = $('#motorOutputReorderDialogOpen');
Expand Down Expand Up @@ -350,10 +358,8 @@ motors.initialize = async function (callback) {
mixerListElement.sortSelect();

function refreshMixerPreview() {
const mixer = FC.MIXER_CONFIG.mixer;
const reverse = FC.MIXER_CONFIG.reverseMotorDir ? "_reversed" : "";

$('.mixerPreview img').attr('src', `./resources/motor_order/${mixerList[mixer - 1].image}${reverse}.svg`);
const imgSrc = getMixerImageSrc(FC.MIXER_CONFIG.mixer, FC.MIXER_CONFIG.reverseMotorDir);
replace_mixer_preview(imgSrc);
}

const reverseMotorSwitchElement = $('#reverseMotorSwitch');
Expand Down

0 comments on commit 5a633c9

Please sign in to comment.