Gilou06

Gilou06

Hi there,
I’m adding an animation to an existing DOM object. To do so I use JS.transition to add a temp CSS class, the call is initiated from the server with a push_event.
Everything looked fine at first, with default 200ms transition time.
But it was not long enough since the animation lasts several seconds.
It needs 4s to complete the animation.
So I bumped the transition time to 4000.
It is all nice now, only Liveview is frozen during 4s. It will buffer user clicks for that duration and then will proceed.
I can’t have a frozen UI for 4s of course.
Do you know if there is a way around this behavior without breaking the “DOM awareness” of JS.transition ?

Thanks
Jean-yves

Showing Posts 1 to 4

soup

soup

I think you will have to write a hook and apply the transitions yourself, either in updated() or in a handleEvent handler.

See also the docs on that linked page for AlpineJS which describes how to copy attributes across updates, which you might want to do to flag “in-transition” elements?

One quirk I noticed is that updated is run even when the dom diff doesn’t effect that element, not sure if that is a bug but you’ll have to watch out for it. edit: in some cases, at least when you have phx-mounted attached.

Probably you could also have multiple/nested liveviews, I think they probably both block their JS independently.

Gilou06

Gilou06 OP

Hi,
I ended up using greensock GSAP libraries. They play along well with LiveView and handle well animation interruptions.
I basically fire event from server with push_event, catch on the client with code declared in app.ps
Example :

window.addEventListener("phx:gsap", ({ detail }) => {
    var tl = gsap.timeline();
    tl.from(detail.zoom, { scale: 1, duration: 0.7 })
    tl.fromTo(detail.zoom, { scale: 1.3 }, { scale: 1, duration: 1 })
    tl.fromTo(detail.wiggle, { opacity: 0, scale: 2 }, { opacity: 1, scale: 1, duration: 0.5, repeat: 1 });
})
ryoung786

ryoung786

Just chiming in to say I hit this issue as well! It makes using the JS.transition (or show/hide with transition option) a no-go with longer animations. I’d love to find a workaround without needing to go to an external library.

Liveview is frozen during 4s. It will buffer user clicks for that duration and then will proceed.

adw632

adw632

It’s certainly horrible.

LiveSvelte is made for this, a disappearing framework, no bloat, powerful animation support which can be trivially embedded in your liveview pages.

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews