W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2009

[whatwg] window.setInterval if visible.

From: João Eiras <joaoe@opera.com>
Date: Thu, 15 Oct 2009 22:02:32 +0200
Message-ID: <op.u1uxyfgg2q99of@coruscant>
On Thu, 15 Oct 2009 21:35:03 +0200, Gregg Tavares <gman at google.com> wrote:

> I was wondering if there as been a proposal for either an optional  
> argument
> to setInterval that makes it only callback if the window is visible OR  
> maybe
> a window.setRenderInterval.

You're trying to solve a real problem with a very specific API. You might  
use setInterval, but someone else might use a worker or setTimeout.

The best way would be an attribute on the window, like window.isVisible  
returning either true of false which would return true if the document is  
partially or totally visible.
This way, all other possible use cases to prevent animations or other  
complex and heavy dom/layout operations could be postponed just by  
checking that value.

I personally think it's a good idea to have that info available.
Received on Thursday, 15 October 2009 13:02:32 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:53 UTC