/*! * ScrollMagic v2.0.5 (2015-04-29) * The javascript library for magical scroll interactions. * (c) 2015 Jan Paepke (@janpaepke) * Project Website: http://scrollmagic.io * * @version 2.0.5 * @license Dual licensed under MIT license and GPL. * @author Jan Paepke - e-mail@janpaepke.de * * @file Debug Extension for ScrollMagic. */ !function(e,r){"function"==typeof define&&define.amd?define(["ScrollMagic"],r):r("object"==typeof exports?require("scrollmagic"):e.ScrollMagic||e.jQuery&&e.jQuery.ScrollMagic)}(this,function(e){"use strict";var r="debug.addIndicators",t=window.console||{},i=Function.prototype.bind.call(t.error||t.log||function(){},t);e||i("("+r+") -> ERROR: The ScrollMagic main module could not be found. Please make sure it's loaded before this plugin or use an asynchronous loader like requirejs.");var o="0.85em",n="9999",s=15,d=e._util,a=0;e.Scene.extend(function(){var e,r=this;r.addIndicators=function(t){if(!e){var i={name:"",indent:0,parent:undefined,colorStart:"green",colorEnd:"red",colorTrigger:"blue"};t=d.extend({},i,t),a++,e=new l(r,t),r.on("add.plugin_addIndicators",e.add),r.on("remove.plugin_addIndicators",e.remove),r.on("destroy.plugin_addIndicators",r.removeIndicators),r.controller()&&e.add()}return r},r.removeIndicators=function(){return e&&(e.remove(),this.off("*.plugin_addIndicators"),e=undefined),r}}),e.Controller.addOption("addIndicators",!1),e.Controller.extend(function(){var t=this,i=t.info(),o=i.container,n=i.isDocument,a=i.vertical,l={groups:[]},g=function(){t._log&&(Array.prototype.splice.call(arguments,1,0,"("+r+")","->"),t._log.apply(this,arguments))};t._indicators&&g(2,"WARNING: Scene already has a property '_indicators', which will be overwritten by plugin."),this._indicators=l;var c=function(){l.updateBoundsPositions()},u=function(){l.updateTriggerGroupPositions()};return o.addEventListener("resize",u),n||(window.addEventListener("resize",u),window.addEventListener("scroll",u)),o.addEventListener("resize",c),o.addEventListener("scroll",c),this._indicators.updateBoundsPositions=function(e){for(var r,t,i,n=e?[d.extend({},e.triggerGroup,{members:[e]})]:l.groups,g=n.length,c={},u=a?"left":"top",p=a?"width":"height",f=a?d.get.scrollLeft(o)+d.get.width(o)-s:d.get.scrollTop(o)+d.get.height(o)-s;g--;)for(i=n[g],r=i.members.length,t=d.get[p](i.element.firstChild);r--;)c[u]=f-t,d.css(i.members[r].bounds,c)},this._indicators.updateTriggerGroupPositions=function(e){for(var r,i,g,c,u,p=e?[e]:l.groups,f=p.length,h=n?document.body:o,m=n?{top:0,left:0}:d.get.offset(h,!0),v=a?d.get.width(o)-s:d.get.height(o)-s,b=a?"width":"height",G=a?"Y":"X";f--;)r=p[f],i=r.element,g=r.triggerHook*t.info("size"),c=d.get[b](i.firstChild.firstChild),u=g>c?"translate"+G+"(-100%)":"",d.css(i,{top:m.top+(a?g:v-r.members[0].options.indent),left:m.left+(a?v-r.members[0].options.indent:g)}),d.css(i.firstChild.firstChild,{"-ms-transform":u,"-webkit-transform":u,transform:u})},this._indicators.updateTriggerGroupLabel=function(e){var r="trigger"+(e.members.length>1?"":" "+e.members[0].options.name),t=e.element.firstChild.firstChild;t.textContent!==r&&(t.textContent=r,a&&l.updateBoundsPositions())},this.addScene=function(r){this._options.addIndicators&&r instanceof e.Scene&&r.controller()===t&&r.addIndicators(),this.$super.addScene.apply(this,arguments)},this.destroy=function(){o.removeEventListener("resize",u),n||(window.removeEventListener("resize",u),window.removeEventListener("scroll",u)),o.removeEventListener("resize",c),o.removeEventListener("scroll",c),this.$super.destroy.apply(this,arguments)},t});var l=function(e,t){var i,o,n=this,s=g.bounds(),l=g.start(t.colorStart),c=g.end(t.colorEnd),u=t.parent&&d.get.elements(t.parent)[0],p=function(){e._log&&(Array.prototype.splice.call(arguments,1,0,"("+r+")","->"),e._log.apply(this,arguments))};t.name=t.name||a,l.firstChild.textContent+=" "+t.name,c.textContent+=" "+t.name,s.appendChild(l),s.appendChild(c),n.options=t,n.bounds=s,n.triggerGroup=undefined,this.add=function(){o=e.controller(),i=o.info("vertical");var r=o.info("isDocument");u||(u=r?document.body:o.info("container")),r||"static"!==d.css(u,"position")||d.css(u,{position:"relative"}),e.on("change.plugin_addIndicators",h),e.on("shift.plugin_addIndicators",f),_(),b(),setTimeout(function(){o._indicators.updateBoundsPositions(n)},0),p(3,"added indicators")},this.remove=function(){if(n.triggerGroup){if(e.off("change.plugin_addIndicators",h),e.off("shift.plugin_addIndicators",f),n.triggerGroup.members.length>1){var r=n.triggerGroup;r.members.splice(r.members.indexOf(n),1),o._indicators.updateTriggerGroupLabel(r),o._indicators.updateTriggerGroupPositions(r),n.triggerGroup=undefined}else w();v(),p(3,"removed indicators")}};var f=function(){b()},h=function(e){"triggerHook"===e.what&&_()},m=function(){var e=o.info("vertical");d.css(l.firstChild,{"border-bottom-width":e?1:0,"border-right-width":e?0:1,bottom:e?-1:t.indent,right:e?t.indent:-1,padding:e?"0 8px":"2px 4px"}),d.css(c,{"border-top-width":e?1:0,"border-left-width":e?0:1,top:e?"100%":"",right:e?t.indent:"",bottom:e?"":t.indent,left:e?"":"100%",padding:e?"0 8px":"2px 4px"}),u.appendChild(s)},v=function(){s.parentNode.removeChild(s)},b=function(){s.parentNode!==u&&m();var r={};r[i?"top":"left"]=e.triggerPosition(),r[i?"height":"width"]=e.duration(),d.css(s,r),d.css(c,{display:e.duration()>0?"":"none"})},G=function(){var r=g.trigger(t.colorTrigger),s={};s[i?"right":"bottom"]=0,s[i?"border-top-width":"border-left-width"]=1,d.css(r.firstChild,s),d.css(r.firstChild.firstChild,{padding:i?"0 8px 3px 8px":"3px 4px"}),document.body.appendChild(r);var a={triggerHook:e.triggerHook(),element:r,members:[n]};o._indicators.groups.push(a),n.triggerGroup=a,o._indicators.updateTriggerGroupLabel(a),o._indicators.updateTriggerGroupPositions(a)},w=function(){o._indicators.groups.splice(o._indicators.groups.indexOf(n.triggerGroup),1),n.triggerGroup.element.parentNode.removeChild(n.triggerGroup.element),n.triggerGroup=undefined},_=function(){var r=e.triggerHook(),t=1e-4;if(!(n.triggerGroup&&Math.abs(n.triggerGroup.triggerHook-r)