sul-dlss / wallscreens

📺 curated experiences for touch-screen installations on the stanford campus
Other
1 stars 0 forks source link

Add autoplay control button #291

Closed thatbudakguy closed 2 years ago

thatbudakguy commented 2 years ago

closes #286 branched from #283 since I didn't want to end up redoing work to reference layouts (and hence draft).

this implementation adds a small play/pause button to control autoplay with a "ring" indicator of how much time is left until the next slide/step. if you advance the slide manually or otherwise interact with the page, the autoplay should deactivate. eventually (after autoplayTimeout elapses without any interaction) it will turn back on again on its own.

note that if you want to test with shorter timer values, you also need to change the CSS that controls the "ring" animation: https://github.com/sul-dlss/wallscreens/blob/89daf9f6941ddc6b1c91e179b0f00a58be24aa7f/_scss/wallscreens/_buttons.scss#L202-L205

this could be made "smarter" (we could actually update the ring to match the interval) but i went with a "dumb" version for the first pass where the animation doesn't actually know about the timer, it just runs for a set amount of time. it seems to work OK.

netlify[bot] commented 2 years ago

✔️ Deploy Preview for sul-wallscreens ready!

🔨 Explore the source changes: 7863e38c76b3da687c9ecc49a7838add40f763de

🔍 Inspect the deploy log: https://app.netlify.com/sites/sul-wallscreens/deploys/61b7a1641f37070007e2c867

😎 Browse the preview: https://deploy-preview-291--sul-wallscreens.netlify.app

ggeisler commented 2 years ago

Thanks for working on this @thatbudakguy, definitely looks like a great start on something that seems feasible and useful. I like the ring solution. To me it's a great compromise between being noticeable but still somewhat subtle and unobtrusive.

I know this is just a draft so not sure which aspects you've thought through and are intentional but here are some initial thoughts, assuming everything is intentional:

Screen Shot 2021-12-07 at 4 56 55 PM
thatbudakguy commented 2 years ago

ok @ggeisler thanks for the feedback — this is ready for another look.

ggeisler commented 2 years ago

@thatbudakguy The autostart looks great and things work well when you just let autoplay to do its thing. Below are things I'm still concerned about, although some of them might be the behavior you intended. For those, just let me know if you did intend it to be like that and we can discuss whether we should stick to that behavior.

Screen Shot 2021-12-09 at 2 37 28 PM

You can see it isn't truly round by how the progress ring doesn't follow the edge as it approaches the bottom:

Screen Shot 2021-12-09 at 2 44 14 PM

It's possible these issues are because I don't have Safari or Chrome device-mode setup correctly (I use Firefox most of the time). So if you and others don't see this issue, it's just me.

The items below are not browser-specific:

thatbudakguy commented 2 years ago

thanks again for reviewing!

ggeisler commented 2 years ago

@thatbudakguy Yeah the font changes messing things up makes sense (sorry!). The button now looks good on Chrome, but in Safari not so much, though again, maybe my device emulation is not set up correctly (I'm using Responsive Design mode and Chrome on Windows as the browser to emulate):

Screen Shot 2021-12-09 at 4 09 22 PM

Sure, we can live with resetting the autoplay interval if it's not simple to fix. We'll see if anyone cares or notices.

I'm glad you could fix the next/previous not stopping autoplay, but now there appears to be a related issue. If autoplay is on (progress ring is moving) and I use either button, the slide navigates as expected but the progress doesn't restart at 0, it starts where the previous slide left off. In other words, if I select Next from slide 1 at 10 seconds in, when we get to slide 2 the progress ring is already at ~11 seconds.

thatbudakguy commented 2 years ago

@ggeisler i tested in safari (my version is Version 15.1 (16612.2.9.1.30, 16612)) and wasn't able to duplicate that strange offset. it looks like safari actually respects aspect-ratio (unlike Chrome), so everything is displaying normally for me. i'm also not even sure the utility of telling Safari on a Mac to emulate Chrome on Windows, so maybe we should shelve this until we know whether the wallscreen itself actually displays this bug.

i added some logic to restart the autoplay advance timer when you click next/prev. it's a little weird (i guess there has to be a sufficient delay of 1ms in order to restart the animation) but it seems to work.

ggeisler commented 2 years ago

@thatbudakguy Yeah, I'm sure it was just my Safari setup being weird. And now that I think about it, we don't really care about Safari (or Firefox, for that matter), in the immediate timeframe, anyway, since our only known target is Chrome on Windows.

I still see some odd/inconsistent behavior when I navigate using Previous/Next (sometimes the timer restarts, but other times it keeps going from where it was on the previous slide), but I'm not confident that what I'm seeing is accurate (I've only been using the Netlify version of this PR). Given we worked out the ideal behavior we're shooting for, I'm happy to someone else to do a technical review and merge this. And then the whole team can maybe verify it is working as expected (and we can see how it looks at Hohbach on Monday).

thatbudakguy commented 2 years ago

ok, autoplay should now pause when the "more info" modal is opened. I didn't add corresponding logic to restart autoplay when the modal is closed, because if the user had opened the modal with autoplay turned off, closing it would still start autoplay even if they didn't want to use it. @ggeisler let me know if this makes sense to you.

ggeisler commented 2 years ago

I didn't add corresponding logic to restart autoplay when the modal is closed, because if the user had opened the modal with autoplay turned off, closing it would still start autoplay even if they didn't want to use it.

@thatbudakguy Sure, seems reasonable, but can you confirm what happens in these scenarios:

  1. User may or may not have autoplay turned off, but opens the More Info modal. Then the user walks away, with the modal window still open. No other users are around. Does the wallscreen remain in this state (displaying the modal) until another user comes along? Or do we still have a timer somewhere that detects when there's been no screen interaction for some_time_interval and then closes the modal and goes into attract mode?
  2. User paused autoplay, opens the modal, reads it, closes it, and walks away. Do we still finish the current experience and go into autoplay?

What I'm getting at is do we still have the more global no visitor interaction for some time interval detection going on so we can't get into a scenario where there are no users but the wallscreen is stuck in a particular state?

I guess I've just gotten confused over whether this new autoplay/pause button has affected our previous strategy of going into attractor mode after no visitor interaction for some time interval.

thatbudakguy commented 2 years ago

both great questions! fortunately the system for entering attract mode is separate from the one for autoplay, so we shouldn't be able to get into a "stuck" state:

  1. the more info modal always tracks how long it's been open without an interaction, and eventually closes itself. at that point, the experience will be tracking how long it's been without any interaction, and eventually resume autoplaying.
  2. same thing here; autoplay will resume on its own after 15 minutes if there's been no interaction of any kind.

to clarify — what i think of as "attract mode" is the situation where we're switching between the experience type index pages. we will always eventually get there, because:

ggeisler commented 2 years ago

@thatbudakguy Okay, great. That all sounds fine then. (I do wonder if we should shorten the interval before going into attract mode -- 15 minutes seems kind of long to be showing some arbitrary state with no one around -- but that's a separate thing we could discuss and maybe change later.)

So I have no objection/would be happy if someone wants to finalize the technical review of this and merge.