Usage
This function runs automatically, so it is not called manually. Is this incorrect?
Demo
Change tabs to see the log:
Additional Notes
This function essentially does the following:
- If a prerender was detected, send an event to Google Analytics and prevent videos from playing.
- If the page was hidden, trigger nebula_page_hidden, add a
page-visibility-hidden
class to the body, and pause all videos. - Otherwise, if the page has become visible, trigger nebula_page_visible and remove the
page-visibility-hidden
from the body. Note: This does not automatically resume videos.
Source File
Located in /assets/js/modules/utilities.js on line 781.
No Hooks
This function does not have any filters or actions available. Request one?
JavaScript
nebula.visibilityChangeActions = function(){ if ( document.visibilityState === 'prerender' ){ //Page was prerendered ga('send', 'event', 'Page Visibility', 'Prerendered', 'Page loaded before tab/window was visible', {'nonInteraction': true}); nebula.pauseAllVideos(false); } if ( document.visibilitystate === 'hidden' ){ //Page is hidden nebula.dom.document.trigger('nebula_page_hidden'); nebula.dom.body.addClass('page-visibility-hidden'); nebula.pauseAllVideos(false); } else { //Page is visible nebula.networkAvailable(); nebula.dom.document.trigger('nebula_page_visible'); nebula.dom.body.removeClass('page-visibility-hidden'); } };
Override
To override or disable this JavaScript function, simply redeclare it with the exact same function name.
JavaScript
nebula.visibilityChangeActions = function(){ //Write your own code here, leave it blank, or return false. }