Delay iron route - Meteor

84 Views Asked by At

I'm using Iron Router and I want to add an animation on the loading template. So I did a transition which takes 1400ms.

Some loading time are faster than the 1400ms and mess up with the animation logic.

So, I want to make loading time take at least 1400ms and I created a Session variable telling when the loading animation is finished.

I tried (in coffee):

Router.onBeforeAction ->
  self = @
  run = null

  routerAvailable = ->
    if Session.get "navAvailable"
      clearInterval(run)
      self.next()

  run = Meteor.setInterval( routerAvailable, 200)

  @stop()

  return

But, it's not working. I get this error message:

Route dispatch never rendered. Did you forget to call this.next() in an onBeforeAction?
0

There are 0 best solutions below