Conversation
|
Given we already support In the long term we want to look at this holistically. Overall we have three distinct capabilities:
We already have It is also worth saying that, if you can block the whole UI with the |
Relates to #3615. Allowing beforeUpdate to cancel an update by returning false is **not** implemented, as this would require more complex internal changes.
|
Still todo: tests |
340efb6 to
55226c4
Compare
55226c4 to
ab80288
Compare
Relates to #3615. Allowing beforeUpdate to cancel an update by returning false is **not** implemented, as this would require more complex internal changes.
Relates to: #3516 When integrating external animation libraries like motion.dev, the existing JS functions are not sufficient. Instead, the third party library needs to be triggered via JS. This has the downside of not being able to block the DOM until the animation is complete, which prevents this from working when elements are removed using `phx-remove`. This commit introduces a new `blocking: true` option to `JS.dispatch/3`, which injects a `done` function into the event's `detail` object. Using this with motion could look like this: ```elixir def render(assigns) do ~H""" <div :if={@show} phx-remove={JS.dispatch("motion:rotate", blocking: true)}> ... </div> """ end ``` ```javascript const { animate } = Motion window.addEventListener("motion:rotate", (e) => { animate(e.target, { rotate: [0, 360] }, { duration: 1 }).then(() => { if (e.detail.done) { e.detail.done() } }) }) ``` It is still necessary to block the DOM while the remove animation is running, as the remove can happen because of a navigation, where the animation would otherwise not run as the whole LiveView is just replaced.
ab80288 to
8fb2c88
Compare
Relates to #3615. Allowing beforeUpdate to cancel an update by returning false is **not** implemented, as this would require more complex internal changes.
Relates to: #3516
When integrating external animation libraries like motion.dev, the existing JS functions are not sufficient. Instead, the third party library needs to be triggered via JS. This has the downside of not being able to block the DOM until the animation is complete, which prevents this from working when elements are removed using
phx-remove.This commit introduces a new
blocking: trueoption toJS.dispatch/3, which injects adonefunction into the event'sdetailobject.Using this with motion could look like this:
It is still necessary to block the DOM while the remove animation is running, as the remove can happen because of a navigation, where the animation would otherwise not run as the whole LiveView is just replaced.