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.
  update: (time) =>
    if not Session.get 'backgroundPaused'
      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…

draw: (time) =>
    return unless @renderer

    if not Session.get 'backgroundPaused'
      vector.update time for key, vector of @vectors
      triangle.draw() for key, triangle of @triangles
      @renderer.render @stage

      frame @draw

The text in the button switches between “Start Background” and “Stop Background” but the background doesn’t resume...

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.
>