0

これをcoffeescriptで使用しようとしています:

  $(this).hide().each (index) ->
    $(this).delay(index * 100).fadeIn 1000, arguments.callee
  $(this).promise().done -> console.log 'hey trip'

au naturale JSでも同じこと

  $(this).hide().each(function(index) {
    $(this).delay(index * 100).fadeIn(1000, arguments.callee)
  });
  $(this).promise().done(function() {console.log 'hey trip' });

アニメーションが完了したら、コンソール ログを実行したいと思います。しかし、このスニペットは、アニメーションが完了したときは言うまでもなく、コンソール メッセージ (一般に) を配信しません。

promise オブジェクトを適切に使用する方法を知っている人はいますか?

2 回目の失敗:

  promise = new $.Deferred ->
  promise.done -> console.log 'hey trip'

  promise.resolve( $(this).hide().each (index) ->
    $(this).delay(index * 100).fadeIn 3000, arguments.callee
  )

3 回目の不合格のバリエーション

dfd = $.Deferred ->
dfd.done(
  $(this).hide().each (index) ->
    $(this).delay(index * 100).fadeIn(3000, arguments.callee)
).done -> console.log 'hey trip'

失敗した 4 番目のバリエーション

$.when(
  $(this).hide().each (index) ->
    $(this).delay(index * 100).fadeIn(3000, arguments.callee)
).then -> console.log 'hey trip' 
4

1 に答える 1

2

へのarguments.calleeパラメータ.fadeIn()です。

それを取り出せば動作します... http://jsfiddle.net/alnitak/9VQ48/を参照してください

于 2012-07-22T21:05:13.573 に答える