;(function (global) {
var lastId = -1;
// Visibility.js allow you to know, that your web page is in the background
// tab and thus not visible to the user. This library is wrap under
// Page Visibility API. It fix problems with different vendor prefixes and
// add high-level useful functions.
var self = {
// Call callback only when page become to visible for user or
// call it now if page is visible now or Page Visibility API
// doesn’t supported.
//
// Return false if API isn’t supported, true if page is already visible
// or listener ID (you can use it in `unbind` method) if page isn’t
// visible now.
//
// Visibility.onVisible(function () {
// startIntroAnimation();
// });
onVisible: function (callback) {
var support = self.isSupported();
if ( !support || !self.hidden() ) {
callback();
return support;
}
var listener = self.change(function (e, state) {
if ( !self.hidden() ) {
self.unbind(listener);
callback();
}
});
return listener;
},
// Call callback when visibility will be changed. First argument for
// callback will be original event object, second will be visibility
// state name.
//
// Return listener ID to unbind listener by `unbind` method.
//
// If Page Visibility API doesn’t supported method will be return false
// and callback never will be called.
//
// Visibility.change(function(e, state) {
// Statistics.visibilityChange(state);
// });
//
// It is just proxy to `visibilitychange` event, but use vendor prefix.
change: function (callback) {
if ( !self.isSupported() ) {
return false;
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.