Skip to content

Commit 691afd0

Browse files
authored
Merge pull request #2115 from WalcoFPV/fix_led_tab
Fix HSV tab in LED tab (Android App)
2 parents 525f18d + c143c0b commit 691afd0

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/js/tabs/led_strip.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
227227
updateColors(ip.eq(i).val(), i);
228228
}
229229

230+
const colorDefineSliders = $('.colorDefineSliders');
231+
230232
// Color Buttons
231233
$('.colors').on('click', 'button', function(e) {
232234
var that = this;
@@ -266,15 +268,26 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
266268
});
267269

268270
$('.colors').on('dblclick', 'button', function() {
269-
$('.colorDefineSliders').css('left', $(this).position().left - $('.colorDefineSliders').width() / 2 + $(this).width());
270-
$('.colorDefineSliders').css('top', $(this).position().top + 26);
271-
$('.colorDefineSliders').show();
271+
const position = $(this).position();
272+
const colorDefineSlidersWidth = colorDefineSliders.width();
273+
const width = $(this).width();
274+
const calc = $(this).offset().left + colorDefineSlidersWidth / 2 + width + 14;
275+
if (calc > $(window).width()) {
276+
colorDefineSliders.css('left', 'auto');
277+
colorDefineSliders.css('right', 0);
278+
} else {
279+
colorDefineSliders.css('left', position.left - colorDefineSlidersWidth / 2 + width);
280+
colorDefineSliders.css('right', 'auto');
281+
}
282+
colorDefineSliders.css('top', position.top + 26);
283+
colorDefineSliders.show();
272284
});
273285

274286
$('.colors').children().on({
275287
mouseleave: function () {
276-
if (!$('.colorDefineSliders').is(":hover"))
277-
$('.colorDefineSliders').hide();
288+
if (!colorDefineSliders.is(":hover")) {
289+
colorDefineSliders.hide();
290+
}
278291
}
279292
});
280293

@@ -585,7 +598,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
585598

586599
});
587600

588-
$('.colorDefineSliders').hide();
601+
colorDefineSliders.hide();
589602

590603
applyFunctionToSelectedLeds();
591604
drawColorBoxesInColorLedPoints();

0 commit comments

Comments
 (0)