R 如何在我的应用程序的面板部分应用自动滚动?

R 如何在我的应用程序的面板部分应用自动滚动?,r,shiny,R,Shiny,我的UI中有一个面板。要求是每当发生事件时,面板应自动下降,无需手动向下滚动。我尝试使用Jscript,但没有解决方案 ui<- fluidPage(titlePanel("Application"), fluidRow(column( width = 8, panel(style = "overflow-y:scroll; max-height: 300px; po

我的UI中有一个面板。要求是每当发生事件时,面板应自动下降,无需手动向下滚动。我尝试使用Jscript,但没有解决方案

ui<- fluidPage(titlePanel("Application"),
               fluidRow(column( width = 8,
                                panel(style = "overflow-y:scroll; max-height: 300px; position:relative; align: centre",
                                      textInput("message", label = "",placeholder = "Type your message here."),
                                      actionButton("send", "Send"), heading = "Education", status = "primary")
               )
               ))

server<- function(input, output, session)
{
  clearInput<- function()
  {
    updateTextInput(session,"message", value = "")
  }
  
  observeEvent(input$send,{
    #Case 1
    insertUI(
      selector = "#message",
      where = "beforeBegin",
      ui=div(class="registration",
             div(class="bubble",
                 wellPanel(
                   p("Please enter your Name")
                 )
             )))
    
    
    if(grepl("^[a-zA-Z][a-zA-Z ]+[a-zA-Z]$",input$message, perl=T))
    {
      insertUI(
        selector = "#message",
        where = "beforeBegin",
        ui=div(class="registration",
               div(class="bubble",
                   wellPanel(
                     p(input$message),
                     p("Please enter your Number")
                   )
                   
               )))
      clearInput()
    }
  })
}
shinyApp(ui,server)

ui单击
send
按钮时自动滚动:

js <- "
$(document).on('shiny:inputchanged', function(event) {
  if (event.name === 'send') {
    var $panel = $('#panel');
    $panel.animate({scrollTop: $panel.prop('scrollHeight')});
  }
});
"

ui<- fluidPage(
  tags$head(tags$script(HTML(js))),
  titlePanel("Application"),
  fluidRow(
    column(
      width = 8,
      panel(id = "panel", 
            style = "overflow-y:scroll; max-height: 300px; position:relative; align: centre",
            textInput("message", label = "", placeholder = "Type your message here."),
            actionButton("send", "Send"), heading = "Education", status = "primary")
    )
  ))

server<- function(input, output, session)
{
  clearInput<- function()
  {
    updateTextInput(session, "message", value = "")
  }
  
  observeEvent(input$send, {
    #Case 1
    insertUI(
      selector = "#message",
      where = "beforeBegin",
      ui=div(class="registration",
             div(class="bubble",
                 wellPanel(
                   p("Please enter your Name")
                 )
             )))
    
    
    if(grepl("^[a-zA-Z][a-zA-Z ]+[a-zA-Z]$",input$message, perl=T))
    {
      insertUI(
        selector = "#message",
        where = "beforeBegin",
        ui=div(class="registration",
               div(class="bubble",
                   wellPanel(
                     p(input$message),
                     p("Please enter your Number")
                   )
                   
               )))
      clearInput()
    }
  })
}

shinyApp(ui,server)


单击
send
按钮时自动滚动:

js <- "
$(document).on('shiny:inputchanged', function(event) {
  if (event.name === 'send') {
    var $panel = $('#panel');
    $panel.animate({scrollTop: $panel.prop('scrollHeight')});
  }
});
"

ui<- fluidPage(
  tags$head(tags$script(HTML(js))),
  titlePanel("Application"),
  fluidRow(
    column(
      width = 8,
      panel(id = "panel", 
            style = "overflow-y:scroll; max-height: 300px; position:relative; align: centre",
            textInput("message", label = "", placeholder = "Type your message here."),
            actionButton("send", "Send"), heading = "Education", status = "primary")
    )
  ))

server<- function(input, output, session)
{
  clearInput<- function()
  {
    updateTextInput(session, "message", value = "")
  }
  
  observeEvent(input$send, {
    #Case 1
    insertUI(
      selector = "#message",
      where = "beforeBegin",
      ui=div(class="registration",
             div(class="bubble",
                 wellPanel(
                   p("Please enter your Name")
                 )
             )))
    
    
    if(grepl("^[a-zA-Z][a-zA-Z ]+[a-zA-Z]$",input$message, perl=T))
    {
      insertUI(
        selector = "#message",
        where = "beforeBegin",
        ui=div(class="registration",
               div(class="bubble",
                   wellPanel(
                     p(input$message),
                     p("Please enter your Number")
                   )
                   
               )))
      clearInput()
    }
  })
}

shinyApp(ui,server)


你所说的“事件发生”是什么意思?哪些事件?每当我单击发送按钮或选择输入时,它都会向下滚动。
找不到功能“面板”
使用了哪些库?@ismirsehegal这是来自
shinyWidgets
。您所说的“事件发生”是什么意思?哪些事件?每当我单击发送按钮或选择输入时,它都会向下滚动。
找不到功能“面板”
使用了哪些库?@ismirsehegal这是来自
shinyWidgets
@AnkushRana的欢迎您。请别忘了。:-)你能给我介绍一下吗@不客气。请别忘了。:-)你能给我介绍一下吗?
if ((['input1','input2']).indexOf(event.name) > -1) {