Sha256: b7be3b04d61f6f4114c2fd75a657f387b5c67fdd0e3587cf8bb52c11410d2e81

Contents?: true

Size: 1.25 KB

Versions: 77

Compression:

Stored size: 1.25 KB

Contents

// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import "@hotwired/turbo-rails"
import "controllers"

document.addEventListener("turbo:before-stream-render", function(event) {
  // Add a class to an element we are about to add to the page
  // as defined by its "data-stream-enter-class"
  if (event.target.firstElementChild instanceof HTMLTemplateElement) {
    var enterAnimationClass = event.target.templateContent.firstElementChild.dataset.streamEnterClass
    if (enterAnimationClass) {
      event.target.templateElement.content.firstElementChild.classList.add(enterAnimationClass)
    }
  }

  // Add a class to an element we are about to remove from the page
  // as defined by its "data-stream-exit-class"
  var elementToRemove = document.getElementById(event.target.target)
  if (elementToRemove) {
    var streamExitClass = elementToRemove.dataset.streamExitClass
    if (streamExitClass) {
      // Intercept the removal of the element
      event.preventDefault()
      elementToRemove.classList.add(streamExitClass)
      // Wait for its animation to end before removing the element
      elementToRemove.addEventListener("animationend", function() {
        event.target.performAction()
      })
    }
  }
})

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
rails_app_generator-0.3.6 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.3.5 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.3.4 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.3.3 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.3.2 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.3.1 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.3.0 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.2.43 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.2.42 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.2.41 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.2.40 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.2.39 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.2.38 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.2.37 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.2.36 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.2.35 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.2.34 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.2.33 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.2.32 after_templates/rag/tailwind_hotwire_form/application.js
rails_app_generator-0.2.31 after_templates/rag/tailwind_hotwire_form/application.js