gpt4 book ai didi

javascript - R Shiny sliderInput 按钮 ---> 页面打开时动画

转载 作者:行者123 更新时间:2023-11-29 10:11:41 24 4
gpt4 key购买 nike

你好,下面是我的 Shiny 应用中 UI 部分开头的代码:

shinyUI(navbarPage("Boston Food Inspections", id="nav",
tabPanel("Interactive map",
div(class="outer",

tags$head(
includeCSS("styles.css")
),
leafletOutput("map", width="100%", height = "100%"),

absolutePanel(id ="controls", class ="panel panel-default", fixed=TRUE,
draggable=TRUE, top=60, left='auto', right=20, bottom='auto',
width=300, height='auto',
checkboxGroupInput("status", h4("Business License Status"), bstatus,
selected = "Active"),
checkboxGroupInput("violations", h4("Violation"), violationType,
selected="Rodents"),
sliderInput('period', h4("Select Time Period"),
min = 2008,
max = 2015,
value = c(2008,2008),
sep="", step=1, ticks=FALSE,animate=animationOptions(loop=T)), round=TRUE
)
)
),

现在我的动画选项指定 slider 将有一个播放/暂停按钮。但是,sliderInput 仅在用户打开应用程序时才开始播放。我想知道是否有人知道更改 javascript 以便 sliderInput 在页面加载后立即开始播放的简单方法?

谢谢。

最佳答案

使用 jQuery 加载页面后,您可以单击该按钮。这是一个例子:

server <- function(input, output) {
}

ui <- fluidPage(
sliderInput("obs", "Number of observations:",
min = 10, max = 500, value = 100,
animate=T),
tags$script("$(document).ready(function(){
setTimeout(function() {$('.slider-animate-button').click()},10);
});")
)

shinyApp(ui = ui, server = server)

tags$script 部分点击按钮。我添加了一个 setTimeout 以将点击延迟 10 毫秒以等待附加点击处理程序。

关于javascript - R Shiny sliderInput 按钮 ---> 页面打开时动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32292125/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com