Last active
December 21, 2015 00:48
-
-
Save cfjedimaster/6222503 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*********************** | |
* 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 | |
//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) ); | |
} | |
//Edge symbol: 'stage' | |
(function(symbolName) { | |
Symbol.bindSymbolAction(compId, symbolName, "creationComplete", function(sym, e) { | |
console.log("Ready to do 2"); | |
mysym=sym.getSymbol("Symbol_1"); | |
mysym2=sym.getSymbol("Symbol_2"); | |
//force it to be block | |
mysym.element.css("display","block"); | |
mysym2.element.css("display","block"); | |
/* | |
A bit hacky - but let's remember what we've already started | |
*/ | |
var mysym1Started = false; | |
var mysym2Started = false; | |
if(isScrolledIntoView(mysym.element)) { | |
mysym.play(0); | |
} else { | |
$(window).on("scroll", function(e) { | |
if(mysym1Started) return; | |
if(isScrolledIntoView(mysym.element)) { | |
console.log('Start me up'); | |
mysym1Started=true; | |
mysym.play(0); | |
//only disable if both visible | |
if(isScrolledIntoView(mysym.element) && isScrolledIntoView(mysym2.element)) { | |
$(window).off("scroll"); | |
} | |
} | |
}); | |
} | |
if(isScrolledIntoView(mysym2.element)) { | |
mysym2.play(0); | |
} else { | |
$(window).on("scroll", function(e) { | |
if(mysym2Started) return; | |
if(isScrolledIntoView(mysym2.element)) { | |
console.log('Start me up 2'); | |
mysym2Started=true; | |
mysym2.play(0); | |
//only disable if both visible | |
if(isScrolledIntoView(mysym.element) && isScrolledIntoView(mysym2.element)) { | |
$(window).off("scroll"); | |
} | |
} | |
}); | |
} | |
}); | |
//Edge binding end | |
})("stage"); | |
//Edge symbol end:'stage' | |
//========================================================= | |
//Edge symbol: 'Symbol_1' | |
(function(symbolName) { | |
})("Symbol_1"); | |
//Edge symbol end:'Symbol_1' | |
//========================================================= | |
//Edge symbol: 'Symbol_2' | |
(function(symbolName) { | |
})("Symbol_2"); | |
//Edge symbol end:'Symbol_2' | |
})(jQuery, AdobeEdge, "EDGE-10866332"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment