Add a way to pause the background animation #220

I currently set href to "" because I don't currently know how to interface with session variables directly through html tags. "Basic View" and "Standard View" have different lengths, so the footer shifts when the button is pressed. The paused background state is different from the paused state when the user once again switches to the tab after a period of time, where the triangles are all orange and regular. The session variable can also be renamed and used elsewhere to perhaps make the page less reactive, for example in displaying search results, to reduce lag.
I reverted the update function:


  update: (time) =>
    distance = Math.sin(Math.min(Math.abs(@originY + 0.5 * @originX + 150 - (time / 2) / 5 % (Math.max(window.innerWidth, window.innerHeight) + 300)) / Math.sqrt(1.25), 200) / 200 * Math.PI / 2) * 60
    if not @duration or time > @start + @duration
      @start = time
      @duration = Math.random() * 2000 + 5000
      @deltaX = Math.random() * 8 + 5
      @deltaY = Math.random() * 20 + 5
      delta = (time - @start) / @duration
      sin = Math.sin(delta * Math.PI * 2)
      @x = @originX + sin * @deltaX + distance
      @y = @originY + sin * @deltaY + distance


and changed the draw function to:


 draw: (time) =>
    return unless @renderer

    if not Session.get 'backgroundPaused'
      vector.update (time - backgroundPausedTime) for key, vector of @vectors
      triangle.draw() for key, triangle of @triangles
      @renderer.render @stage
    else
      backgroundPausedTime = time;

    frame @draw


but now the background is stuck, even after pausing then resuming the background so backgroundPausedTime is set to time. When I replace the bolded text with “time” there is random lag and the background changes more sporadically.

On Jul 1, 2014, at 11:52 AM, Mitar <notifications@github.com> wrote:

> In client/lib/background.coffee:
> 
> > @@ -34,6 +34,7 @@ class Vector
> >      @deltaY = 0
> >  
> >    update: (time) =>
> > +    return if Session.get 'backgroundPaused'
> I do not think that would work. But I am not exactly sure what you are proposing. You do not have an update loop at all. You have to start it. And then it will go on by itself.
> 
> —
> Reply to this email directly or view it on GitHub.
>