RinteRface / fullPage

📄 fullPage.js, pagePiling.js and multiScroll.js for shiny
https://fullpage.rinterface.com
Other
110 stars 12 forks source link

rand function generates ids with leading numeric #5

Closed zac-garland closed 4 years ago

zac-garland commented 4 years ago

Great job on the package @JohnCoene

One small fix.. the current rand function often generates id's with leading numerics. Which often causes issues with that slide / page, etc.

reprex below and new proposed function

set.seed(123)

# old
rand <- function(){
  paste0(tolower(sample(c(LETTERS, 1:9), 26 + 9)), collapse = "")
}

for(i in 1:10) print(rand())
#> [1] "k1n34bpyolx96mcreafw7jizh2svut8dg5q"
#> [1] "qzhk7emljd8f6xsaiocuyb1w4gtrn295v3p"
#> [1] "1vxaoglrjc4q92zis7pubwehd536ky8nfmt"
#> [1] "69une3ibzsd8vm4wgfyroc2th17pkqj5xla"
#> [1] "knaf1g4c3tvli62h9dzrqew8py5buos7mjx"
#> [1] "vmr2szjthp8gyu5fx7ko96ib4cwed31lanq"
#> [1] "qihvb6klwx7z9p5yj32osftacdug8ern1m4"
#> [1] "zn65whgq48tejksu2myipx9afol7brdv31c"
#> [1] "1enhbl5g3r6c9tpqswzm4aki28v7dxojfyu"
#> [1] "39hl1zietcaxy75mfnosvj8qk2bru4gd6wp"

# proposed

rand <- function(){
  rand_id <- paste0(tolower(sample(c(LETTERS, 1:9), 26 + 9)), collapse = "")
  paste0(sample(letters,1),rand_id)
}

for(i in 1:10) print(rand())
#> [1] "xe7qft45livd9ughpyazw8x26mjobck1s3nr"
#> [1] "qgjd95iv3c6z1x2uwrkyhsbe47lno8qmfpat"
#> [1] "tuk49jleyzoixfnc5b63t8r72msdw1vpagqh"
#> [1] "sfe7no8qhgr2tcsipmukadjw651zxy4v39lb"
#> [1] "hd8ibvxk3hcjemltg76ou5zfyasnq12p49wr"
#> [1] "q7xo1bwk89huctgp45ynve2z3flj6dairqms"
#> [1] "rn2s3r85lz7ka9y1qtgocejm6fxiwhvpbu4d"
#> [1] "thkfzeyj8rcaxn1spu4twl7v5di26qg9om3b"
#> [1] "h3otz2lcru9h851j4npwayekvbx6qg7dfsmi"
#> [1] "lot1g9nvuwxz4mdkfaljceipb53h7s8ry26q"

Created on 2020-08-05 by the reprex package (v0.3.0)

zac-garland commented 4 years ago

For context, here's an example. If you run this a few times, you'll see that the page is blank for any of the ID's that start with a numeric.

library(shiny)
library(fullPage)

pics <- jsonlite::fromJSON("https://picsum.photos/v2/list")$download_url

ui <- fullPage(
  center = TRUE,
  fullSection(
    lapply(pics[1:15],function(x){
      fullSlideImage(
      img = x
    )
    })
  )
)

server <- function(input, output){}

shinyApp(ui, server)
JohnCoene commented 4 years ago

Thanks Zac that looks great. I'm happy to implement that unless you want to create a PR.

zac-garland commented 4 years ago

Hi John, no problem! I will create a PR this afternoon or tomorrow morning.

JohnCoene commented 4 years ago

Thank you!

zac-garland commented 4 years ago

@JohnCoene no problem, thanks for implementing and great job on the package!

JohnCoene commented 4 years ago

Ehhhh I forgot to ask; please feel free to re-do a PR to add yourself as contributor.