gadenbuie / countdown

⏲ countdown timer for R Markdown slides and HTML docs
https://pkg.garrickadenbuie.com/countdown
150 stars 15 forks source link

Ability to cancel timer #3

Closed ConnorJPSmith closed 5 years ago

ConnorJPSmith commented 5 years ago

Currently:

Say we started a timer with a sound, but turns out we finish a minute early. We advance to the next slide, then after 60 seconds we get an unexpected sound.

Solutions: 1) Add some way to cancel a timer or force it to complete 2) Make timers not persist after advancing slide (bad idea, would be nice to be able to move to another slide if needed while its still running) 3) Make timer not make sound when not in the active slide

Caveat: I am not too familiar with slides, so not sure if 2 or 3 are actionable

gadenbuie commented 5 years ago

Thanks for the thoughtful feedback! This occurred to me too and I considered many of the same options.

I think solution 3 is feasible -- slides that are visible have .remark-visible in the parent div, and I could check for that class before playing the sound. But this would be entirely xaringan/remarkjs dependent. From a quick SO search, generally checking for visibility of elements is a bit of a mess without jQuery.

OTOH, there's an easy (albeit brute-force) way to cancel a timer: refresh the page. In my experience xaringan slides reload quickly even with slides with heavy graphics, and the current position is retained, so it shouldn't be too disrupting. Just hit F5 or +R when you finish early to reset the timer.