Skip to content

Instantly share code, notes, and snippets.

@cfjedimaster
Created April 11, 2013 01:33
Show Gist options
  • Save cfjedimaster/5359941 to your computer and use it in GitHub Desktop.
Save cfjedimaster/5359941 to your computer and use it in GitHub Desktop.
/***********************
* Adobe Edge Animate Composition Actions
*
* Edit this file with caution, being careful to preserve
* function signatures and comments starting with 'Edge' to maintain the
* ability to interact with these actions from within Adobe Edge Animate
*
***********************/
(function($, Edge, compId){
var Composition = Edge.Composition, Symbol = Edge.Symbol; // aliases for commonly used Edge classes
//Edge symbol: 'stage'
(function(symbolName) {
Symbol.bindSymbolAction(compId, symbolName, "creationComplete", function(sym, e) {
// insert code to be run when the symbol is created here
console.log('Start');
var thisScrollHandler = function(e) {
if(isScrolledIntoView(sym.element)) {
console.log('Start me up');
sym.play(0);
$(window).off("scroll", thisScrollHandler);
}
}
//http://stackoverflow.com/a/488073/52160
function isScrolledIntoView(elem)
{
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
var elemTop = $(elem).offset().top;
var elemBottom = elemTop + $(elem).height();
return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom)
&& (elemBottom <= docViewBottom) && (elemTop >= docViewTop) );
}
if(isScrolledIntoView(sym.element)) {
sym.play(0)
} else {
$(window).on("scroll", thisScrollHandler);
}
});
//Edge binding end
Symbol.bindElementAction(compId, symbolName, "${_play}", "click", function(sym, e) {
sym.play();
});
//Edge binding end
})("stage");
//Edge symbol end:'stage'
})(jQuery, AdobeEdge, "EDGE-4894298");
@pojitonov
Copy link

Could you explain how to setup this script in Edge Animate, I put it at stage on CreationComplete Action and it is doesn't work for me.

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