Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visibility API #87

Open
justmarkup opened this issue Jan 24, 2012 · 14 comments
Open

Visibility API #87

justmarkup opened this issue Jan 24, 2012 · 14 comments

Comments

@justmarkup
Copy link

I think the Visibility API is worth a mention.

Currently there is native support for Chrome > 13, IE 10 and Firefox 10 although only with prefixes.

Pollyfills:

In my opinion the status should be "Use with pollyfills" .

What do you think?

@addyosmani
Copy link
Contributor

I've used both of the above polyfills/shims in production. I think mine and evilmartians both need more/tests, but they do the trick. I would say 'use with polyfills'.

@Raynos
Copy link
Contributor

Raynos commented Jan 24, 2012

Defiantly worth mentioning. Neiter appear to be polyfills they are just feature equivelant emulation using propietory APIs.

Writing a real polyfill shouldn't be too difficult though.

@nimbupani
Copy link
Member

If this is proprietary API I think we should mention with 'avoid'. We shouldnt have to face the trauma of flexbox again.

@Raynos
Copy link
Contributor

Raynos commented Jan 24, 2012

That's not what I meant. I meant the polyfills don't use the native API. (the polyfills use their own propietory API, except the term "propietory API" is poorly used to describe that).

Page Visibility is a proper w3c specification.

@nimbupani
Copy link
Member

ohh i see. perhaps then we need a good polyfill that DOES use the native API?

@addyosmani
Copy link
Contributor

So, to add some further clarity to the comment from @Raynos, both solutions do use the Page Visibility API in it's native form if it's present, but do so and provide fallbacks through an abstraction layer. This was necessary as we were experiencing (IE) issues related to just firing off simulated 'visibilityChanged' events that prevented us from just doing a 100% polyfill. If anyone feels they can improve on that, by all means please do :)

@Raynos
Copy link
Contributor

Raynos commented Jan 24, 2012

Would firing visibilityChanged events through an emulated DOM2 events (addEventListener) API in oldIE count as a 100% polyfill? That should be possible. Also DOM 0 event listeners like document.onvisibilitychange should also be possible.

I'll add writing a page visibility polyfill to the list.

@addyosmani
Copy link
Contributor

It would cover the most important part of the spec, but if you're going for completeness there's a little more to it such as exposing the actual state and not just that it's changed :)

On 24 Jan 2012, at 18:54, [email protected] wrote:

Would firing visibilityChanged events through an emulated DOM2 events (addEventListener) API in oldIE count as a 100% polyfill? That should be possible. Also DOM 0 event listeners like document.onvisibilitychange should also be possible.

I'll add writing a page visibility polyfill to the list.


Reply to this email directly or view it on GitHub:
#87 (comment)

@Raynos
Copy link
Contributor

Raynos commented Jan 25, 2012

The following polyfill : https://gist.github.com/1677020 given some polish and testing should work correctly.

Note that legacy browser support in this case requires polyfilling addEventListener, [].forEach and Object.defineProperty which should all be shimmable back to oldIE.

@jonathantneal
Copy link
Member

If it helps make things feel more native in old ie, you could use a combination onpropertychange and toString = function() to make your polyfill act and feel more native (i use it as a poor man's object.watch)

@reconbot
Copy link

reconbot commented Feb 1, 2012

@Raynos that works for me, thank you thank you!

@nimbupani
Copy link
Member

@Raynos what is your view on this? Would you be up to making a new post on Visibility API?

@Raynos
Copy link
Contributor

Raynos commented Feb 19, 2013

Its worth mentioning yes, not sure what I would write about it, may get around to it.

@arthurvr
Copy link
Member

Do you guys think there's still a need for 'use with polyfill'? Take a look at the caniuse page, but looks like it's overall quite green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants