 makeTransitionFunc = (func, transitionClass, removeClass, state, evt, test) ->
   (time) ->
     promise = new Promise()
-    nextTick =>
+    requestAnimationFrame =>
       # Start the transition if the view is rendered and the test function
       # return true.
       if @rendered and test.call(@)

makeVisibilityFunc = (visibility, evt, test, testRejectionMsg) ->
  ->
    promise = new Promise()
    nextTick =>
      if @rendered
        if test.call @
          if @transitioning
            @_stopTransition("Transition canceled by #{evt} event.")
          @['_' + evt]()
          @context.visibility = visibility


        # Set the new transition timer.
        @_transitionTimer = setTimeout =>
          @_transitionTimer = null
          Promise.resolve promise, @[func].call(@)
        , (time or 0)

