Skip to content

Commit 5a633c9

Browse files
authored
Fix: Mixer preview images in web builds (#3567)
* Fix: Mixer preview images in web builds * Fix: Mixer preview images in web builds * Refactor: Use function
1 parent c111129 commit 5a633c9

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/css/tabs/motors.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
border-bottom: 1px solid var(--subtleAccent);
5555
}
5656
.mixerPreview {
57-
img {
57+
svg {
5858
width: 150px;
5959
height: 150px;
6060
margin-left: 15px;

src/js/tabs/motors.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,17 @@ motors.initialize = async function (callback) {
227227
lines.attr('d', graphHelpers.line);
228228
}
229229

230+
function replace_mixer_preview(imgSrc) {
231+
$.get(imgSrc, function(data) {
232+
const svg = $(data).find('svg');
233+
$('.mixerPreview').html(svg);
234+
}, 'xml');
235+
}
236+
230237
function update_model(mixer) {
231238
const imgSrc = getMixerImageSrc(mixer, FC.MIXER_CONFIG.reverseMotorDir);
232-
$('.mixerPreview img').attr('src', imgSrc);
239+
240+
replace_mixer_preview(imgSrc);
233241

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

352360
function refreshMixerPreview() {
353-
const mixer = FC.MIXER_CONFIG.mixer;
354-
const reverse = FC.MIXER_CONFIG.reverseMotorDir ? "_reversed" : "";
355-
356-
$('.mixerPreview img').attr('src', `./resources/motor_order/${mixerList[mixer - 1].image}${reverse}.svg`);
361+
const imgSrc = getMixerImageSrc(FC.MIXER_CONFIG.mixer, FC.MIXER_CONFIG.reverseMotorDir);
362+
replace_mixer_preview(imgSrc);
357363
}
358364

359365
const reverseMotorSwitchElement = $('#reverseMotorSwitch');

0 commit comments

Comments
 (0)