Fix #1400: Using sliders / colorwheel sometimes slides the whole UI (#1459)

* Prevent UI from sliding when using sliders (#1400)

An iro.js version bump in commit 98e4ac6 changed names for the slider &
colorwheel classes which made the filter in function lock() fail.

Also it seems that not all elements of the Iro sliders & colorwheel have
appropriate classes set. Just changing the names still sometimes failed
when the user accidentally grabbed a part of the slider / colorwheel
that has no class name set.

To mitigate this, lock() now checks the events classlist for classes
starting with "Iro" as well as it's parents classlist if no "Iro" classes
were found

* Regenerate wled00/html_ui.h
pull/1464/head
Maik Allgöwer 2020-12-09 14:08:05 +01:00 zatwierdzone przez GitHub
rodzic bdaef7e541
commit 7684fb83d6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 1433 dodań i 1421 usunięć

Wyświetl plik

@ -2443,10 +2443,23 @@ let iSlide = 0, x0 = null, scrollS = 0, locked = false, w;
function unify(e) { return e.changedTouches ? e.changedTouches[0] : e } function unify(e) { return e.changedTouches ? e.changedTouches[0] : e }
function hasIroClass(classList) {
for (var i = 0; i < classList.length; i++) {
var element = classList[i];
if (element.startsWith('Iro')) return true;
}
return false;
}
function lock(e) { function lock(e) {
if (pcMode) return; if (pcMode) return;
var l = e.target.classList; var l = e.target.classList;
if (l.contains('noslide') || l.contains('iro__wheel__saturation') || l.contains('iro__slider__value') || l.contains('iro__slider')) return; var pl = e.target.parentElement.classList;
if (l.contains('noslide') || hasIroClass(l) || hasIroClass(pl)) return;
x0 = unify(e).clientX; x0 = unify(e).clientX;
scrollS = d.getElementsByClassName("tabcontent")[iSlide].scrollTop; scrollS = d.getElementsByClassName("tabcontent")[iSlide].scrollTop;

Plik diff jest za duży Load Diff