この JSFiddle を参照してください: http://jsfiddle.net/5mUsH/3/
AngularJS と jQuery で本当に単純な JavaScript アニメーションを実行しようとしています。(古いブラウザーをサポートし、より複雑なアニメーションも実行したいので、CSS アニメーションは使用していません。) フィドルのコードは AngularJS ユーザー ガイドからのものです (ただし、少し簡略化されています): http://docs.angularjs.org/ガイド/アニメーション
しかし、うまくいきません!DOM はすぐに (アニメーションなしで) 更新されます。何か案は?ありがとう!
JSFiddle からの関連するマークアップは次のとおりです。
<div class="sample" ng-show="checked">
Visible...
</div>
そして JavaScript:
angular.module('App', ['ngAnimate']).animation('.sample', function() {
return {
enter : function(element, done) {
element.css('opacity',0);
jQuery(element).animate({
opacity: 1
}, done);
// optional onDone or onCancel callback
// function to handle any post-animation
// cleanup operations
return function(isCancelled) {
if(isCancelled) {
jQuery(element).stop();
}
}
},
leave : function(element, done) {
element.css('opacity', 1);
jQuery(element).animate({
opacity: 0
}, done);
// optional onDone or onCancel callback
// function to handle any post-animation
// cleanup operations
return function(isCancelled) {
if(isCancelled) {
jQuery(element).stop();
}
}
},
}
});