Repeated items - setting/clearing item background on condition with a time duration

Hi there,

I have a list of items (data collection from Xano). I want to highlight a new element in this list right after it’s been added. And I want a highlight duration to last 5 seconds.

I achieved it, but don’t think I used an optimal way for this :sweat_smile:

Now it works like this:

  1. User adds a new element to the list through the modal

  2. With “on mounted” workflow binded to an item I change a “legalFormHighlight” variable to “true” for a 5 seconds (time delay). And then change it back to “false”.


  1. The “legalFormHighlight” variable changes the state of each item from “Default” to “New item”

  2. Inside the “New item” state in the background color field I check with JS if an item was added recently. And if it was I paint the background.

So, my approach seems pretty complicated to me. Maybe there’s an easier option.

For a transient animation, I’d consider putting CSS to work instead of JS. THere’s good documentation about how to use CSS animations: CSS Animations | WeWeb Documentation

The cool thing is that you can apply them on the mount of theocmponent, so somethingnew coming in gets the animation (be it movement, a glow, or whatever).

@raydeck , thanks, appreciate your input.

Am I getting it right, that nevertheless, I still need to somehow manage setting/clearing a highlight automatically for a specific period of time?

I tried it with a variable, but a variable is taken by all repetead items as a single entity, which is the same for all. So, when even one of the items meets the highlight condition they are all highlighted which is wrong behavior for my case.

The animation can just be appplied to the element. It fires once, and then it has nothing more to do. Make the animation the default behavior on mount. No variable required.

Sorry for being silly :blush:
Didn’t think about it that way.

Pretty sure it’s a solution. Will try to implement. Thank you!

Tried it. Works almost as I need it to, except the part that the animation fires on page load event for every item inside the repeated items list. So it highlights all the items on any data fetch.

And I want the animation to fire only for items that are considered “new” by my condition, which is that their creation date is no more than 10 seconds from the current time.

As I undestand, in order to make the animation work right I’ll need to track all the conditions when animation should or shouldn’t fire. And set for all those conditions play state “paused” or “running”. Sounds like a challenge :slight_smile: