Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoAttendant #137

Open
kinto-b opened this issue Jun 30, 2023 · 0 comments
Open

autoAttendant #137

kinto-b opened this issue Jun 30, 2023 · 0 comments

Comments

@kinto-b
Copy link

kinto-b commented Jun 30, 2023

Stellar package!

I think it would be handy to have an autoAttendantBar() which behaves similarly to autoWaiter(), i.e. it is shown on shiny:recalculating and closed on shiny:error or shiny:value.

Also, inspired by the behaviour of NProgress I think it would be more satisfying visually if:

  1. The automatic increase interval was not fixed but rather depended on the value of the progress bar so that the bar initially increases quickly and then slows down as we approach the end.

  2. The progress bar was finished off before being hidden when it is closed.

i.,e. this kind of behaviour:

# Increase by decaying interval
pbNext <- function(pb, x0 = 0.1, rate = 5) {
  next_val <- pb$getVal() + x0*exp(-rate*pb$getVal())
  pb$up(next_val)
}

# When finished, increase by random amount, wait, then increase to end
pbDone <- function(pb, ms = 100) {
  nextval <- pb$getVal() + runif(1, 0, 1-pb$getVal())
  pb$up(nextval)
  Sys.sleep(ms/1000)
  pb$up(1)
  close(pb)
}

pb <- utils::txtProgressBar()
while (pb$getVal() < 1) {
  Sys.sleep(0.1)
  
  # Imagine we hit `shiny:value` just after progbar crosses midway
  if (pb$getVal()<0.6) {
    pbNext(pb)
  } else {
    pbDone(pb)
  }
}

Relevant parts of NProgress here: https://github.com/rstacruz/nprogress/blob/e1a8b7fb6e059085df5f83c45d3c2308a147ca18/nprogress.js#L148-L177

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant