Skip to content

Commit

Permalink
turbo morph frames + stimulus
Browse files Browse the repository at this point in the history
  • Loading branch information
palkan committed Oct 10, 2023
1 parent f732f67 commit 7c31539
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 6 additions & 0 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ document.addEventListener("turbo:before-render", (event) => {
});
};
});

document.addEventListener("turbo:before-frame-render", (event) => {
event.detail.render = (prevEl, newEl) => {
Idiomorph.morph(prevEl, newEl.children, { morphStyle: "innerHTML" });
};
});
4 changes: 0 additions & 4 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { Application } from "@hotwired/stimulus";
import AnimatedNumber from "stimulus-animated-number";

const application = Application.start();

// Configure Stimulus development experience
application.debug = new URLSearchParams(window.location.search).has("debug");
window.Stimulus = application;

// Register third-party controllers
application.register("animated-number", AnimatedNumber);

// Eager load all controllers defined in the import map under controllers/**/*_controller
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading";
eagerLoadControllersFrom("controllers", application);

0 comments on commit 7c31539

Please sign in to comment.