angular 4 animations - transition duration is not applied

给你一囗甜甜゛ 提交于 2019-12-11 02:46:28

问题


what am I doing wrong? The transition happens but it's instant. The time set in animate function is not being applied

trigger('showMenu', [
  state('active', style({
    marginLeft: '0px'
  })),
  state('inactive', style({
    marginLeft: '-230px'
  })),
  transition('inactive => active', animate('2s')),
  transition('active => inactive', animate('2s'))
])

<div [@showMenu]="showMenuState" id="menu-side-wrapper">
    MENU
    <div id="close-menu">
       CLOSE
    </div>
</div>

回答1:


I've checked the code you've pasted here and it works fine. Could you add any other relevant code? Maybe the code for 'showMenuState'?




回答2:


I fixed the exact problem in my project by removing the import of NoopAnimationsModule in my main module. This one seems to mock the animations, but actually doesn't do a thing.



来源:https://stackoverflow.com/questions/43193229/angular-4-animations-transition-duration-is-not-applied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!