Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Some code via https://support.google.com/richmedia/answer/2672554?hl=en
// The Function below tests to see if the DFP enabler has been loaded.
// The DFP Enabler is embedded in the <head> of this document.
// You can edit the contents of the <head>…</head> of your exported .html file by clicking on 'Edit HTML Head' in the Document Inspector.
// If it has loaded, then the main timeline is 'continued'
// This should happen fairly quickly.
// If true, start function. If false, listen for INIT.
window.onload = function() {
if (Enabler.isInitialized()) {
enablerInitHandler();
} else {
Enabler.addEventListener(studio.events.StudioEvent.INIT,
enablerInitHandler);
}
}
function enablerInitHandler() {
// Start ad, initialize animation,
// load in your image assets, call Enabler methods,
// and/or include other Studio modules.
// Also, you can start the Polite Load
// On the main timeline, the Timeline has a 'pause' action, so this resumes it
hypeDocument.continueTimelineNamed('Main Timeline', hypeDocument.kDirectionForward);
}
// If true, start function. If false, listen for PAGE_LOADED.
// Insert this code inside your enablerInitHandler function
if (Enabler.isPageLoaded()) {
pageLoadedHandler();
} else {
Enabler.addEventListener(studio.events.StudioEvent.PAGE_LOADED,
pageLoadedHandler);
}
//The following code out of the enablerInitHandler function:
function pageLoadedHandler() {
// Load in additional assets or add animation/video
//hypeDocument.continueTimelineNamed('Main Timeline', hypeDocument.kDirectionForward);
}
// The Code below starts your animation only if it is visible. Again, run a 'continue timeline' action in line 74
// To use this option.
// If true, start function. If false, listen for VISIBLE.
// So your pageLoadedHandler function will look like the following:
function pageLoadedHandler() {
if (Enabler.isVisible()) {
adVisibilityHandler();
} else {
Enabler.addEventListener(studio.events.StudioEvent.VISIBLE,
adVisibilityHandler);
}
}
function adVisibilityHandler() {
// Page has loaded and ad is visible:
hypeDocument.continueTimelineNamed('Main Timeline', hypeDocument.kDirectionForward);
}
@themorgantown

This comment has been minimized.

Copy link
Owner Author

@themorgantown themorgantown commented Aug 3, 2016

For more info on this snippet, visit: http://forums.tumult.com/t/howto-deploying-hype-animations-to-double-click-studio/1367

Suggestions for improvement appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.