Skip to content

Router animation not working if animated element are not set to position: fixed or absolute #19501

@rernens

Description

@rernens

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

When routing animation is used to animate route :enter or leave, animate transition is not run if animated view is not positionned fixed or absolute.

The following animation will not work as expected

trigger('routerAnimations', [
 transition( '* <=> *', [
    group([
    query( ':leave', [
      animate('500ms ease-in-out',
        style( {
          opacity: 0,
        })
      )
    ],{ optional: true }),
    query( ':enter', [
        style( {
          opacity: 0,
        }),
        animate('2s 250ms ease-in-out',
          style( {
            opacity: 1
          })
        )
      ],{ optional: true }),
    ])
  ])
])

while the following animation works as expected

trigger('routerAnimations', [
  transition( '* <=> *', [
    query(':enter,:leave', [
      style({
        position: 'fixed'
      })
    ],{ optional: true }),
    group([
    query( ':leave', [
      animate('500ms ease-in-out',
        style( {
          opacity: 0,
        })
      )
    ],{ optional: true }),
      query( ':enter', [
        style( {
          opacity: 0,
        }),
        animate('2s 250ms ease-in-out',
          style( {
            opacity: 1
          })
        )
      ],{ optional: true }),
    ])
  ])
])

Expected behavior

positionning the element should not be required to trigger animation

Minimal reproduction of the problem with instructions

http://embed.plnkr.co/xwCLlw6VHGpRW2n1Q7Gj/

What is the motivation / use case for changing the behavior?

forcing positionning fixed on the animated element might change its appearance during the animation compared to its normal appearance

Environment


Angular version: 4.4.4


Browser:
- [x] Chrome (desktop) Version 61.0.3163.100 (Build officiel) (64 bits)
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [x] Safari (desktop) Version 11.0 (12604.1.38.1.7)
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: 8.1 
- Platform:  MacOS Sierra 12.6

Others:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions