animator-css icon indicating copy to clipboard operation
animator-css copied to clipboard

Update before animation if interpolation in element class

Open RomkeVdMeulen opened this issue 9 years ago • 11 comments

I'm following this guide and expected to see something like:

expected behaviour

Instead I got:

actual behaviour

Not sure what I'm doing wrong: my code is essentially the same as in the guide.

<template class="au-stagger">
    <div repeat.for="item of feedbackService.items" class="au-animate feedback-item level-${item.level}">
        <a click.trigger="feedbackService.removeItem(item)" href="#" class="fa fa-times-circle"></a>
        <p>${item.message}</p>
    </div>
</template>
export class FeedbackService {

    private static REMOVE_DELAY_MS = 5000;

    public items: FeedbackItem[] = [];

    addItem(item: FeedbackItem) {
        this.items.push(item);
        if (item.autohide) {
            setTimeout(
                () => this.removeItem(item),
                FeedbackService.REMOVE_DELAY_MS * this.items.filter((item) => item.autohide).length
            );
        }
    }

    removeItem(item: FeedbackItem) {
        let index = this.items.indexOf(item);
        if (index > -1) {
            this.items.splice(index, 1);
        }
    }
}
.feedback-item {
    &.au-enter {
        max-height: 0;
    }
    &.au-enter-active {
        animation: feedbackUp 1s;
    }
    &.au-leave-active {
        animation: feedbackDown 1s;
    }
}

@keyframes feedbackUp {
    0%   { max-height: 0; }
    100% { max-height: 102px; }
}

@keyframes feedbackDown {
    0%   { max-height: 102px; }
    100% { max-height: 0; }
}

RomkeVdMeulen avatar May 10 '16 08:05 RomkeVdMeulen

without a full example it's hard to replicate the issue, but I guess it might be because you've placed the class au-stagger onto the template tag. Please try to wrap the animated divs with another div and place the au-stagger over there, like

<template>
  <div class="au-stagger">
    <div repeat.for="item of feedbackService.items" class="au-animate feedback-item level-${item.level}">
        <a click.trigger="feedbackService.removeItem(item)" href="#" class="fa fa-times-circle"></a>
        <p>${item.message}</p>
    </div>
  </div>
</template>

zewa666 avatar May 10 '16 08:05 zewa666

After a lot of trial-and-error I've found that the problem only occurs when there's interpolation in the animated element's class list.

I've created an Plunkr demonstrating the issue. The top three items have class interpolation, the bottom three don't. See what happens when you try to remove item number 2.

RomkeVdMeulen avatar May 10 '16 12:05 RomkeVdMeulen

hmm I've looked at your example few times and don't really have a clue what the error or bug is you're trying to point out.

zewa666 avatar May 10 '16 13:05 zewa666

That's strange... I'm seeing this bug in both Chrome and Firefox. Here's a screencast of what I'm seeing:

screencast

When I click to remove item 2, it briefly becomes blue before folding. Same thing when I remove item 1. This happens with the top three items which have an interpolated className, but not the bottom three that use inline styling.

You're not getting this?

RomkeVdMeulen avatar May 10 '16 16:05 RomkeVdMeulen

oh ok now I understand what you mean. Yep I can see the same effect. Hmmm honestly I have no clue whats causing this, guess maybe something related to how the ViewSlots are added and removed. @martingust and @EisenbergEffect do you maybe have an idea whats causing the issue with the class interpolation?

zewa666 avatar May 11 '16 05:05 zewa666

Any progress on this?

RomkeVdMeulen avatar May 30 '16 09:05 RomkeVdMeulen

@RomkeVdMeulen I have analyzed this issue (today) and I think I know where the problem lies. I'll get back to you on this.

niieani avatar May 31 '16 20:05 niieani

@niieani Did you have any feedback on this?

EisenbergEffect avatar Jul 06 '16 19:07 EisenbergEffect

Haven't had the time to work on this yet, just did some preliminary assessment. It's on my list though.

niieani avatar Jul 06 '16 22:07 niieani

stale since 2016

Alexander-Taran avatar Mar 02 '18 21:03 Alexander-Taran

I ran into this issue again today so I thought I'd poke this old issue in the hopes it won't be completely forgotten.

RomkeVdMeulen avatar Jun 03 '19 11:06 RomkeVdMeulen