Skip to content

Commit ac010cd

Browse files
authored
Merge pull request wled#1378 from andyshinn/feature/slider-value-display
Display tooltip with value on slider change
2 parents adbeb4a + d0c94ba commit ac010cd

File tree

2 files changed

+2187
-2121
lines changed

2 files changed

+2187
-2121
lines changed

wled00/data/index.htm

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,23 @@
441441
z-index: -1;
442442
}
443443

444+
.sliderbubble {
445+
width: 36px;
446+
line-height: 24px;
447+
background: var(--c-3);
448+
position: absolute;
449+
transform: translateX(-50%);
450+
border-radius: 12px;
451+
margin-left: 12px;
452+
margin-top: 3px;
453+
padding: 0px;
454+
display: inline;
455+
}
456+
457+
.hidden {
458+
display: none;
459+
}
460+
444461
input[type=range] {
445462
-webkit-appearance: none;
446463
width: 220px;
@@ -480,6 +497,10 @@
480497
background: var(--c-f);
481498
transform: translateY(7px);
482499
}
500+
input[type=range]:active + .sliderbubble {
501+
display: inline;
502+
transform: translateX(-50%);
503+
}
483504

484505
#wwrap {
485506
display: none;
@@ -882,6 +903,12 @@
882903
background: var(--c-sbh);
883904
}
884905

906+
@media all and (max-width: 335px) {
907+
.sliderbubble {
908+
display: none;
909+
}
910+
}
911+
885912
@media all and (max-width: 550px) and (min-width: 374px) {
886913
.infobtn {
887914
width: 155px;
@@ -1002,6 +1029,7 @@
10021029
<i class="icons slider-icon">&#xe325;</i>
10031030
<div class="sliderwrap il">
10041031
<input id="sliderSpeed" class="noslide" onchange="setSpeed()" oninput="updateTrail(this)" max="255" min="0" type="range" value="128" />
1032+
<output class="sliderbubble hidden"></output>
10051033
<div class="sliderdisplay"></div>
10061034
</div>
10071035
</div>
@@ -1010,6 +1038,7 @@
10101038
<i class="icons slider-icon" onclick="tglLabels()">&#xe409;</i>
10111039
<div class="sliderwrap il">
10121040
<input id="sliderIntensity" class="noslide" onchange="setIntensity()" oninput="updateTrail(this)" max="255" min="0" type="range" value="128" />
1041+
<output class="sliderbubble hidden"></output>
10131042
<div class="sliderdisplay"></div>
10141043
</div>
10151044
</div>
@@ -1298,6 +1327,13 @@
12981327
size();
12991328
d.getElementById("cv").style.opacity=0;
13001329
if (localStorage.getItem('pcm') == "true") togglePcMode(true);
1330+
var sls = d.querySelectorAll('input[type="range"]');
1331+
for (var sl of sls) {
1332+
sl.addEventListener('input', updateBubble, true);
1333+
sl.addEventListener('touchstart', toggleBubble);
1334+
sl.addEventListener('touchend', toggleBubble);
1335+
}
1336+
13011337
}
13021338

13031339
function updateTablinks(tabI)
@@ -1677,6 +1713,21 @@
16771713
e.parentNode.getElementsByClassName('sliderdisplay')[0].style.background = val;
16781714
}
16791715

1716+
function updateBubble(e)
1717+
{
1718+
var bubble = e.target.parentNode.getElementsByTagName('output')[0]
1719+
var max = e.target.hasAttribute('max') ? e.target.attributes.max.value : 255;
1720+
1721+
if (bubble) {
1722+
bubble.innerHTML = e.target.value
1723+
}
1724+
}
1725+
1726+
function toggleBubble(e)
1727+
{
1728+
e.target.parentNode.querySelector('output').classList.toggle('hidden');
1729+
}
1730+
16801731
function updateLen(s)
16811732
{
16821733
if (!d.getElementById(`seg${s}s`)) return;

0 commit comments

Comments
 (0)