leongersen / noUiSlider

noUiSlider is a lightweight, ARIA-accessible JavaScript range slider with multi-touch and keyboard support. It is fully GPU animated: no reflows, so it is fast; even on older devices. It also fits wonderfully in responsive designs and has no dependencies.
https://refreshless.com/nouislider/
MIT License
5.64k stars 658 forks source link

draw a red line for current time on slider? no issue #1206

Closed ldijkman closed 1 year ago

ldijkman commented 2 years ago

Hello

my question fits better in Discussions tab (but it is not activated on this repo?)

anyone maybe has an idea how to draw a red line marker on slider for current time or a link to an example

greet luberth https://ldijkman.github.io/Electra/schedule.html https://github.com/ldijkman/randomnerd_esp32_wifi_manager/tree/main/LAB_Experiments#timed-switching

2022-06-26-080745_1920x1080_scrot

ldijkman commented 2 years ago

this draws a vertical red line at 50% wich is 12 o clock but it messes up the slider

<style>
    .noUi-base{
        border-left: 2px solid red;
        height: 20px;
        position:absolute;
        left: 50%;
    }
</style>

or should i add a div to .noUi-base via javascript code
position percentage of current time versus 24h

2022-06-26-175914_1920x1080_scrot

ldijkman commented 2 years ago

still trying created a div from script at 50% on 1st slider

https://ldijkman.github.io/Electra/schedule.html

2022-06-27-194929_1920x1080_scrot

leongersen commented 2 years ago

Hi Luberth,

I think the easiest way to achieve this is to fit the slider in a div with position: relative, then use another div (position: absolute; left: 50%) for the line.

ldijkman commented 2 years ago

to my surprise i got it a bit working

javascript adds a div class actualtime to nouibase left position percentage is based on actual time

https://ldijkman.github.io/Electra/schedule.html

2022-06-28-060607_1920x1080_scrot

leongersen commented 2 years ago

Okay, glad you worked it out! 👍

ldijkman commented 2 years ago

monday slider if actualtime in range "light on" change color to yellow else green

https://ldijkman.github.io/Electra/schedule.html 2022-06-30-214717_1920x1080_scrot

ldijkman commented 2 years ago

and a sunrise marker

https://ldijkman.github.io/Electra/schedule.html

2022-07-03-113906_1920x1080_scrot

github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.