title: Animation on conditionalpanel
body: <p>I want some animation on my conditionalpanels. I've found the solution provided here:
  <a href="https://stackoverflow.com/questions/62972563/animation-transition-for-shiny-conditionalpanel">Animation/transition for Shiny conditionalPanel</a></p>
  <p>I really like the solution, but I have a problem. Check the following example:</p>
  <pre><code>library(shiny)
  library(shinyjs)
  library(shinydashboard)
  
  ui &lt;- dashboardPage(
    header = dashboardHeader(title = &quot;test&quot;),
    sidebar = dashboardSidebar(),
    shinydashboard::dashboardBody(
      fluidPage(
        useShinyjs(),
        
        tags$head(
          tags$link(rel = &quot;stylesheet&quot;, href = &quot;https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.0/animate.compat.min.css&quot;),
          tags$script(src = &quot;https://cdnjs.cloudflare.com/ajax/libs/animateCSS/1.2.2/jquery.animatecss.min.js&quot;)
        ),
        
        fluidRow(
          textOutput(&quot;test&quot;),
          column(2, offset = 2, actionButton(&quot;prev_box&quot;, &quot;Previous&quot;)),
          column(
            4,
            
            # conditionalPanel(condition = &quot;output.phase_box_ui == 0&quot;,
            #                  uiOutput(&quot;box_move1&quot;)),
            # conditionalPanel(condition = &quot;output.phase_box_ui &gt; 0&quot;,
            #                  uiOutput(&quot;box_move2&quot;))
            
  
            animatedConditionalPanel(
              condition = &quot;output.phase_box_ui == 0&quot;,
              onShow = animateCSS(&quot;backInRight&quot;, duration = 1000),
              onHide = animateCSS(&quot;backOutLeft&quot;, duration = 1000),
              fadeIn = 0,
              fadeOut = 0,
              uiOutput(&quot;box_move1&quot;)
            ),
            animatedConditionalPanel(
              condition = &quot;output.phase_box_ui == 1&quot;,
              onShow = animateCSS(&quot;backInRight&quot;, duration = 1000),
              onHide = animateCSS(&quot;backOutLeft&quot;, duration = 1000),
              fadeIn = 0,
              fadeOut = 0,
              uiOutput(&quot;box_move2&quot;)
            )
            
          ),
          column(2, actionButton(&quot;next_box&quot;, &quot;Next&quot;))
        )
      )
    )
  )
  
  server &lt;- function(input, output,session) {
  
    #### TEST BOX MOVING
    
    phase_box = reactiveVal(0)
    
    observeEvent(phase_box(),{
      if(phase_box() == 0){
        shinyjs::hide(&quot;prev_box&quot;)
      }else{
        shinyjs::show(&quot;prev_box&quot;)
      }
    })
    
    
    observeEvent(input$prev_box,{
      if(phase_box() &gt; 0){
        val = phase_box() - 1
        phase_box(val)
      }
    })
    
    observeEvent(input$next_box,{
      if(phase_box() &lt; 6){
        val = phase_box() + 1
        phase_box(val)
      }
    })
    
    output$test = renderText({
      phase_box()
    })
    
    output$phase_box_ui = reactive({return(phase_box())})
    outputOptions(output, &quot;phase_box_ui&quot;, suspendWhenHidden = F)
    
    
    
    output$box_move1 = renderUI({
      shinydashboard::infoBox(title = &quot;First box&quot;, value = 0, color = &quot;red&quot;)
  
    })
    
    
    output$box_move2 = renderUI({
      shinydashboard::infoBox(title = &quot;Second box&quot;, value = 1)
    })
    
  }
  
  shinyApp(ui, server)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/ViUqY.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ViUqY.gif" alt="enter image description here" /></a></p>
  <p>The problem is at startup where both of them appear for a second and then disappear, but at startup the first box should be visible. How I can fix it?</p>
  <p><strong>EDIT:</strong></p>
  <p>Now the first problem is solved. However check the gif below:</p>
  <p><a href="https://i.stack.imgur.com/ZcyKm.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZcyKm.gif" alt="enter image description here" /></a></p>
  <p>When the second box arrives, it arrives below the first box and then suddenly it goes up. The effect can be nice if the transition wasn't immediately (it simply pops up in the correct place). Do you know if there is a solution? It's seems like, just for a moment (during the transition), they are displayed both and so the second box goes below the first.</p>
  <p>Here is the behaviour adding 1s delay for the inShow transition of the second box. Maybe is more clear the problem.</p>
  <p><a href="https://i.stack.imgur.com/OINRF.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OINRF.gif" alt="enter image description here" /></a></p>
  <p><strong>EDIT2:</strong></p>
  <p>I have a bigger problem on nested conditionalpanels. When I put another conditionalpanel (a simple one) inside the animated, every time is triggered the inside condition, the animated run again the animation. Here's a reproducible example:</p>
  <pre><code>library(shiny)
  library(shinyjs)
  library(shinydashboard)
  
  ui &lt;- dashboardPage(
    header = dashboardHeader(title = &quot;test&quot;),
    sidebar = dashboardSidebar(),
    shinydashboard::dashboardBody(
      fluidPage(
        useShinyjs(),
        
        tags$head(
          tags$link(rel = &quot;stylesheet&quot;, href = &quot;https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.0/animate.compat.min.css&quot;),
          tags$script(src = &quot;https://cdnjs.cloudflare.com/ajax/libs/animateCSS/1.2.2/jquery.animatecss.min.js&quot;)
        ),
        
        fluidRow(
          textOutput(&quot;test&quot;),
          column(2, offset = 2, actionButton(&quot;prev_box&quot;, &quot;Previous&quot;)),
          column(
            4,
            
            animatedConditionalPanel(
              condition = &quot;output.phase_box_ui == 0&quot;,
              onShow = animateCSS(&quot;backInRight&quot;, duration = 1000),
              onHide = animateCSS(&quot;backOutLeft&quot;, duration = 1000),
              fadeIn = 0,
              fadeOut = 0,
              uiOutput(&quot;box_move1&quot;)
            ),
            animatedConditionalPanel(
              condition = &quot;output.phase_box_ui == 1&quot;,
              onShow = animateCSS(&quot;backInRight&quot;, duration = 1000),
              onHide = animateCSS(&quot;backOutLeft&quot;, duration = 1000),
              fadeIn = 0,
              fadeOut = 0,
              uiOutput(&quot;box_move2&quot;)
            )
            
          ),
          column(2, actionButton(&quot;next_box&quot;, &quot;Next&quot;))
        )
      )
    )
  )
  
  server &lt;- function(input, output,session) {
    
    #### TEST BOX MOVING
    
    phase_box = reactiveVal(0)
    
    observeEvent(phase_box(),{
      if(phase_box() == 0){
        shinyjs::hide(&quot;prev_box&quot;)
      }else{
        shinyjs::show(&quot;prev_box&quot;)
      }
    })
    
    
    observeEvent(input$prev_box,{
      if(phase_box() &gt; 0){
        val = phase_box() - 1
        phase_box(val)
      }
    })
    
    observeEvent(input$next_box,{
      if(phase_box() &lt; 6){
        val = phase_box() + 1
        phase_box(val)
      }
    })
    
    output$test = renderText({
      phase_box()
    })
    
    output$phase_box_ui = reactive({return(phase_box())})
    outputOptions(output, &quot;phase_box_ui&quot;, suspendWhenHidden = F)
    
    
    
    output$box_move1 = renderUI({
      fluidPage(
        shinydashboard::infoBox(title = &quot;First box&quot;, value = 0, color = &quot;red&quot;),
        selectInput(&quot;step2&quot;, &quot;Choose:&quot;, choices = c(&quot;one&quot;, &quot;two&quot;)), br(),
        conditionalPanel(style = &quot;display: none&quot;,
          condition = &quot;input.step2 == 'two'&quot;,
          h4(strong(&quot;2. This is the second step&quot;))
        )
      )
    })
    
    
    output$box_move2 = renderUI({
      shinydashboard::infoBox(title = &quot;Second box&quot;, value = 1)
    })
    
  }
  
  shinyApp(ui, server)
  </code></pre>