debug.addIndicators.min.js 6.9 KB

12
  1. /* ScrollMagic v2.0.7 | (c) 2019 Jan Paepke (@janpaepke) | license & info: http://scrollmagic.io */
  2. !function(a,b){"function"==typeof define&&define.amd?define(["ScrollMagic"],b):"object"==typeof exports?b(require("scrollmagic")):b(a.ScrollMagic||a.jQuery&&a.jQuery.ScrollMagic)}(this,function(d){var f="0.85em",e="9999",j=d._util,c=0;d.Scene.extend(function(){var h,b=this;b.addIndicators=function(i){if(!h){var k={name:"",indent:0,parent:void 0,colorStart:"green",colorEnd:"red",colorTrigger:"blue"};i=j.extend({},k,i),c++,h=new g(b,i),b.on("add.plugin_addIndicators",h.add),b.on("remove.plugin_addIndicators",h.remove),b.on("destroy.plugin_addIndicators",b.removeIndicators),b.controller()&&h.add()}return b},b.removeIndicators=function(){return h&&(h.remove(),this.off("*.plugin_addIndicators"),h=void 0),b}}),d.Controller.addOption("addIndicators",!1),d.Controller.extend(function(){var b=this,i=b.info(),o=i.container,k=i.isDocument,p=i.vertical,n={groups:[]};this._indicators=n;var q=function(){n.updateBoundsPositions()},s=function(){n.updateTriggerGroupPositions()};return o.addEventListener("resize",s),k||(window.addEventListener("resize",s),window.addEventListener("scroll",s)),o.addEventListener("resize",q),o.addEventListener("scroll",q),this._indicators.updateBoundsPositions=function(m){for(var y,A,v,x=m?[j.extend({},m.triggerGroup,{members:[m]})]:n.groups,w=x.length,z={},l=p?"left":"top",h=p?"width":"height",u=p?j.get.scrollLeft(o)+j.get.width(o)-15:j.get.scrollTop(o)+j.get.height(o)-15;w--;){for(y=(v=x[w]).members.length,A=j.get[h](v.element.firstChild);y--;){z[l]=u-A,j.css(v.members[y].bounds,z)}}},this._indicators.updateTriggerGroupPositions=function(m){for(var A,C,w,y,x=m?[m]:n.groups,B=x.length,l=k?document.body:o,h=k?{top:0,left:0}:j.get.offset(l,!0),v=p?j.get.width(o)-15:j.get.height(o)-15,z=p?"width":"height",D=p?"Y":"X";B--;){C=(A=x[B]).element,w=A.triggerHook*b.info("size"),y=j.get[z](C.firstChild.firstChild)<w?"translate"+D+"(-100%)":"",j.css(C,{top:h.top+(p?w:v-A.members[0].options.indent),left:h.left+(p?v-A.members[0].options.indent:w)}),j.css(C.firstChild.firstChild,{"-ms-transform":y,"-webkit-transform":y,transform:y})}},this._indicators.updateTriggerGroupLabel=function(h){var l="trigger"+(1<h.members.length?"":" "+h.members[0].options.name),m=h.element.firstChild.firstChild;m.textContent!==l&&(m.textContent=l,p&&n.updateBoundsPositions())},this.addScene=function(h){this._options.addIndicators&&h instanceof d.Scene&&h.controller()===b&&h.addIndicators(),this.$super.addScene.apply(this,arguments)},this.destroy=function(){o.removeEventListener("resize",s),k||(window.removeEventListener("resize",s),window.removeEventListener("scroll",s)),o.removeEventListener("resize",q),o.removeEventListener("scroll",q),this.$super.destroy.apply(this,arguments)},b});var g=function(A,z){var D,k,b=this,E=a.bounds(),w=a.start(z.colorStart),v=a.end(z.colorEnd),B=z.parent&&j.get.elements(z.parent)[0];z.name=z.name||c,w.firstChild.textContent+=" "+z.name,v.textContent+=" "+z.name,E.appendChild(w),E.appendChild(v),b.options=z,b.bounds=E,b.triggerGroup=void 0,this.add=function(){k=A.controller(),D=k.info("vertical");var i=k.info("isDocument");B||(B=i?document.body:k.info("container")),i||"static"!==j.css(B,"position")||j.css(B,{position:"relative"}),A.on("change.plugin_addIndicators",F),A.on("shift.plugin_addIndicators",C),y(),x(),setTimeout(function(){k._indicators.updateBoundsPositions(b)},0)},this.remove=function(){if(b.triggerGroup){if(A.off("change.plugin_addIndicators",F),A.off("shift.plugin_addIndicators",C),1<b.triggerGroup.members.length){var i=b.triggerGroup;i.members.splice(i.members.indexOf(b),1),k._indicators.updateTriggerGroupLabel(i),k._indicators.updateTriggerGroupPositions(i),b.triggerGroup=void 0}else{q()}h()}};var C=function(){x()},F=function(i){"triggerHook"===i.what&&y()},h=function(){E.parentNode.removeChild(E)},x=function(){var i;E.parentNode!==B&&(i=k.info("vertical"),j.css(w.firstChild,{"border-bottom-width":i?1:0,"border-right-width":i?0:1,bottom:i?-1:z.indent,right:i?z.indent:-1,padding:i?"0 8px":"2px 4px"}),j.css(v,{"border-top-width":i?1:0,"border-left-width":i?0:1,top:i?"100%":"",right:i?z.indent:"",bottom:i?"":z.indent,left:i?"":"100%",padding:i?"0 8px":"2px 4px"}),B.appendChild(E));var l={};l[D?"top":"left"]=A.triggerPosition(),l[D?"height":"width"]=A.duration(),j.css(E,l),j.css(v,{display:0<A.duration()?"":"none"})},q=function(){k._indicators.groups.splice(k._indicators.groups.indexOf(b.triggerGroup),1),b.triggerGroup.element.parentNode.removeChild(b.triggerGroup.element),b.triggerGroup=void 0},y=function(){var l=A.triggerHook();if(!(b.triggerGroup&&Math.abs(b.triggerGroup.triggerHook-l)<0.0001)){for(var n,o=k._indicators.groups,m=o.length;m--;){if(n=o[m],Math.abs(n.triggerHook-l)<0.0001){return b.triggerGroup&&(1===b.triggerGroup.members.length?q():(b.triggerGroup.members.splice(b.triggerGroup.members.indexOf(b),1),k._indicators.updateTriggerGroupLabel(b.triggerGroup),k._indicators.updateTriggerGroupPositions(b.triggerGroup))),n.members.push(b),b.triggerGroup=n,void k._indicators.updateTriggerGroupLabel(n)}}if(b.triggerGroup){if(1===b.triggerGroup.members.length){return b.triggerGroup.triggerHook=l,void k._indicators.updateTriggerGroupPositions(b.triggerGroup)}b.triggerGroup.members.splice(b.triggerGroup.members.indexOf(b),1),k._indicators.updateTriggerGroupLabel(b.triggerGroup),k._indicators.updateTriggerGroupPositions(b.triggerGroup),b.triggerGroup=void 0}!function(){var i=a.trigger(z.colorTrigger),p={};p[D?"right":"bottom"]=0,p[D?"border-top-width":"border-left-width"]=1,j.css(i.firstChild,p),j.css(i.firstChild.firstChild,{padding:D?"0 8px 3px 8px":"3px 4px"}),document.body.appendChild(i);var s={triggerHook:A.triggerHook(),element:i,members:[b]};k._indicators.groups.push(s),b.triggerGroup=s,k._indicators.updateTriggerGroupLabel(s),k._indicators.updateTriggerGroupPositions(s)}()}}},a={start:function(b){var h=document.createElement("div");h.textContent="start",j.css(h,{position:"absolute",overflow:"visible","border-width":0,"border-style":"solid",color:b,"border-color":b});var i=document.createElement("div");return j.css(i,{position:"absolute",overflow:"visible",width:0,height:0}),i.appendChild(h),i},end:function(b){var h=document.createElement("div");return h.textContent="end",j.css(h,{position:"absolute",overflow:"visible","border-width":0,"border-style":"solid",color:b,"border-color":b}),h},bounds:function(){var b=document.createElement("div");return j.css(b,{position:"absolute",overflow:"visible","white-space":"nowrap","pointer-events":"none","font-size":f}),b.style.zIndex=e,b},trigger:function(b){var k=document.createElement("div");k.textContent="trigger",j.css(k,{position:"relative"});var l=document.createElement("div");j.css(l,{position:"absolute",overflow:"visible","border-width":0,"border-style":"solid",color:b,"border-color":b}),l.appendChild(k);var h=document.createElement("div");return j.css(h,{position:"fixed",overflow:"visible","white-space":"nowrap","pointer-events":"none","font-size":f}),h.style.zIndex=e,h.appendChild(l),h}}});