Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The initial style() is applied with delay, when using stagger() #17412

Closed
MrCroft opened this issue Jun 12, 2017 · 7 comments · Fixed by #17534
Closed

The initial style() is applied with delay, when using stagger() #17412

MrCroft opened this issue Jun 12, 2017 · 7 comments · Fixed by #17534

Comments

@MrCroft
Copy link

MrCroft commented Jun 12, 2017

I'm submitting a ... (check one with "x")

[x] bug report

Current behavior
When using stagger(), the initial style() is applied on each individual item, after the stagger delay.

Expected behavior
The initial style() should be applied to all matching items before stagger() kicks in.

Minimal reproduction of the problem with instructions
https://plnkr.co/edit/MWC78V9Hbukl1xD25wW2?p=preview

Please tell us about your environment:

  • Angular version: 4.2.1

  • Browser: all

EDIT: Seems that plnkr isn't working anymore... Noticed this yesterday (June 14th) GET https://run.plnkr.co/DYWkt10odM0YhhTj/tslib 404 () and it's still broken. So, the above example isn't working anymore.

@maxschwarzmueller
Copy link

Using Angular 4.2.2, the example from https://angular.io/api/animations/stagger also is not working as expected (so do all other tries of getting stagger to work).
All items are shown in the "final position" right from the start and then simply moved into that position via the staggered animation again. Expected behavior of course would be for the elements to not start in their ending state but be animated there.

@MrCroft
Copy link
Author

MrCroft commented Jun 15, 2017

@maxschwarzmueller Looking over the code of this demo, I've managed to make it work with something like this:

export const fadeInStagger = trigger('fadeIn', [
    transition(':enter', [
        // style({ /* */ }), // << This would actually be applied on the element the trigger is on
        query('.item-class', [ // << this sets initial style on the children we target
            style({ 'opacity': '0' })
        ]),
        query('.item-class', [ // << animate the children that matches the selector
            stagger(100, animate(400, style({ 'opacity': 1 })))
        ])
    ])
]);

for:

<my-carousel @fadeIn>
    <div class="item-class"
        *ngFor="let item of items">
        <img [src]="item.image" alt="" />
    </div>
</my-carousel>

It seems that we also have to query for setting initial style.
By the way, using 4.2.2 now - don't think it matters, but just to be clear in case it does.

@matsko In the light of the recent "discovery", I think this is not an issue anymore, but rather the docs need a bit more improvement?

EDIT: Sorry for all the above... I've just realized, it kind of isn't related to the code in my plnkr example :) I just got tangled in all the things I try lately, with all the new stuff the animations package provides us. And I'm also a bit tired right now. But I'm not going to delete it, maybe it's a scenario that will help others when coming across this.

@matsko
Copy link
Contributor

matsko commented Jun 15, 2017

Thank you @MrCroft for this. Here's the fix for that #17534

@MrCroft
Copy link
Author

MrCroft commented Jun 15, 2017

Just realized... my previous comment isn't 100% related to the issue. Just got tangled in all the things I keep trying lately, with the new stuff that the animations package provides us. Sorry about that @maxschwarzmueller

@maxschwarzmueller
Copy link

maxschwarzmueller commented Jun 15, 2017

@MrCroft Okay, I misunderstood you, too then ;). Still, the behavior seems to be unintended, you shouldn't have to query the element and change the style before you stagger() in my opinion.

@MrCroft
Copy link
Author

MrCroft commented Jun 15, 2017

@maxschwarzmueller Yes, definitely.
It seems it's fixed now, as Matias mentioned above. Hopefully, it will be published with the next update.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants