thooyork / thooClock

jQuery analogue AlarmClock Plugin
MIT License
30 stars 17 forks source link

Setting dialBackgroundColor based on Day/Night #19

Closed paolobriones closed 4 years ago

paolobriones commented 4 years ago

After instantiating the thooClock, is it possible to set the dialBackgroundColor to another color on the onEverySecond() function?

thooyork commented 4 years ago

Its not possible to set the color from outside the plugin like this. It would be possible to destroy the plugin and re initialize it with the new color, a dirty solution would be:

assume in your html:

<div id="myclock"></div>
<button id="changecolor">change BG color</button>

$(document).ready(function(){

        $('#myclock').thooClock({dialBackgroundColor:'#FFCC74'}); // old color while init

        $('#changecolor').on('click', function(){
            $('#myclock').html('').thooClock({dialBackgroundColor:'green'}) // set new color
        });

.... rest of the code

paolobriones commented 4 years ago

gotcha, it isnt exactly what i was hoping for, will have to find a different way to change the dial color. Thanks!