Sol*_*ake 2 javascript angularjs ng-animate ng-show
我在最新的angularJS版本1.1.5中测试动画,看起来它不能正常工作.请检查这个小提琴
HTML:
<div ng-app>
<div ng-controller='ctrl'>
<input type='button' value='click' ng-click='clicked()' />
<div ng-show="foo == true" class='myDiv' ng-animate="{show: 'fadeIn', hide:'fadeOut'}">
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.myDiv{
width:400px;
height:200px;
background-color:red;
}
.fadeIn-setup, .fadeOut-setup {
-webkit-transition: 1s linear opacity;
-moz-transition: 1s linear opacity;
-o-transition: 1s linear opacity;
transition: 1s linear opacity;
}
.fadeIn-setup{
opacity:0;
}
.fadeOut-setup{
opacity:1;
}
.fadeIn-setup.fadeIn-start {
opacity: 1;
}
.fadeOut-setup.fadeOut-start{
opacity:0;
}
Run Code Online (Sandbox Code Playgroud)
AngularJS:
function ctrl($scope){
$scope.foo = false;
$scope.clicked = function(){
$scope.foo = !($scope.foo);
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我切换回1.1.4版本时,它工作正常但有另一个错误,他们说它已在v1.1.5中修复.现在这令人困惑.他们修复了以前的错误吗?无论如何,任何帮助将不胜感激.
因此,经过几个小时的挖掘,我发现了解决方案,所有文档都已过时,并且未更新到最新的API.这是解决方案:
https://github.com/angular/angular.js/commit/11f712bc
根据更改日志:
The CSS transition classes have changed suffixes. To migrate rename:
.foo-setup {...} to .foo {...}
.foo-start {...} to .foo-active {...}
or for type: enter, leave, move, show, hide:
.foo-type-setup {...} to .foo-type {...}
.foo-type-start {...} to .foo-type-active {...}