-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHypeScrollMagic.pluginDebug.min.js
18 lines (18 loc) · 6.37 KB
/
HypeScrollMagic.pluginDebug.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
Hype ScrollMagic Plugin Debug v1.0.0
Forked from official Scroll Magic Repository (version 2.0.8) by Jan Paepke - [email protected],
copyright (c) 2024 , Max Ziebell (https://maxziebell.de). MIT license and GPL
*/
!1==="HypeScrollMagicPluginDebug"in window&&(window.HypeScrollMagicPluginDebug=function(){if(window.ScrollMagic){var f=ScrollMagic._util,y=0;ScrollMagic.Scene.extend(function(){var a=this,b;a.addIndicators=function(e){b||(e=f.extend({},{name:"",indent:0,parent:void 0,colorStart:"green",colorEnd:"red",colorTrigger:"blue"},e),y++,b=new z(a,e),a.on("add.plugin_addIndicators",b.add),a.on("remove.plugin_addIndicators",b.remove),a.on("destroy.plugin_addIndicators",a.removeIndicators),a.on("progress.plugin_addIndicators",
function(g){b&&b.updateTriggerVisibility(g.progress)}),a.controller()&&b.add());return a};a.removeIndicators=function(){b&&(b.remove(),this.off("*.plugin_addIndicators"),b=void 0);return a}});ScrollMagic.Controller.addOption("addIndicators",!1);ScrollMagic.Controller.extend(function(){var a=this,b=a.info(),e=b.container,g=b.isDocument,k=b.vertical,n={groups:[]};this._indicators=n;var p=function(){n.updateBoundsPositions()},m=function(){n.updateTriggerGroupPositions()};e.addEventListener("resize",
m);g||(window.addEventListener("resize",m),window.addEventListener("scroll",m));e.addEventListener("resize",p);e.addEventListener("scroll",p);this._indicators.updateBoundsPositions=function(d){d=d?[f.extend({},d.triggerGroup,{members:[d]})]:n.groups;for(var q=d.length,r={},t=k?"left":"top",u=k?"width":"height",c=k?f.get.scrollLeft(e)+30+10:f.get.scrollTop(e)+20+10,h,l;q--;)l=d[q],h=f.get[u](l.element.firstChild),r[t]=c+h,f.css(l.members[0].bounds,r)};this._indicators.updateTriggerGroupPositions=function(d){d=
d?[d]:n.groups;var q=d.length,r=g?document.body:e;r=g?{top:0,left:0}:f.get.offset(r,!0);for(var t=k?10:20,u=k?"width":"height",c=k?"Y":"X",h,l,v,w;q--;)h=d[q],l=h.element,v=h.triggerHook*a.info("size"),w=f.get[u](l.firstChild.firstChild),w=v>w?"translate"+c+"(-100%)":"",f.css(l,{top:r.top+(k?v:t-h.members[0].options.indent),left:r.left+(k?t-h.members[0].options.indent:v)}),f.css(l.firstChild.firstChild,{transform:w})};this._indicators.updateTriggerGroupLabel=function(d){var q="trigger "+d.members[0].options.name;
d=d.element.firstChild.firstChild;d.textContent!==q&&(d.textContent=q,k&&n.updateBoundsPositions())};this.addScene=function(d){this._options.addIndicators&&d instanceof ScrollMagic.Scene&&d.controller()===a&&d.addIndicators();this.$super.addScene.apply(this,arguments)};this.destroy=function(){e.removeEventListener("resize",m);g||(window.removeEventListener("resize",m),window.removeEventListener("scroll",m));e.removeEventListener("resize",p);e.removeEventListener("scroll",p);this.$super.destroy.apply(this,
arguments)};return a});var z=function(a,b){var e=this,g=x.bounds(),k=x.start(b.colorStart),n=x.end(b.colorEnd),p=b.parent&&f.get.elements(b.parent)[0],m,d;b.name=b.name||y;k.firstChild.textContent+=" "+b.name;n.textContent+=" "+b.name;g.appendChild(k);g.appendChild(n);e.options=b;e.bounds=g;e.triggerGroup=void 0;this.updateTriggerVisibility=function(c,h){if(this.bounds){var l=1>c?1:0;this.bounds.style.transition=h?"none":"opacity 0.2s "+(0==l?"1s":"0s");this.bounds.style.opacity=l}this.triggerGroup&&
this.triggerGroup.element&&(l=0===c||1===c?0:1,this.triggerGroup.element.style.transition=h?"none":"opacity 0.2s "+(0===l?"1s":"0s"),this.triggerGroup.element.style.opacity=l)};this.add=function(){d=a.controller();m=d.info("vertical");var c=d.info("isDocument");p||(p=c?document.body:d.info("container"));c||"static"!==f.css(p,"position")||f.css(p,{position:"relative"});a.on("change.plugin_addIndicators",r);a.on("shift.plugin_addIndicators",q);u();t();this.updateTriggerVisibility(a.progress(),!0);setTimeout(function(){d._indicators.updateBoundsPositions(e)},
0)};this.remove=function(){e.triggerGroup&&(a.off("change.plugin_addIndicators",r),a.off("shift.plugin_addIndicators",q),d._indicators.groups.splice(d._indicators.groups.indexOf(e.triggerGroup),1),e.triggerGroup.element.parentNode.removeChild(e.triggerGroup.element),e.triggerGroup=void 0,g.parentNode.removeChild(g))};var q=function(){t()},r=function(c){"triggerHook"===c.what&&u()},t=function(){if(g.parentNode!==p){var c=d.info("vertical");f.css(k.firstChild,{"border-bottom-width":c?1:0,"border-right-width":c?
0:1,bottom:c?-1:b.indent,right:c?b.indent:-1,padding:c?"0 8px":"2px 4px"});f.css(n,{"border-top-width":c?1:0,"border-left-width":c?0:1,top:c?"100%":"",right:c?b.indent:"",bottom:c?"":b.indent,left:c?"":"100%",padding:c?"0 8px":"2px 4px"});p.appendChild(g)}c={};c[m?"top":"left"]=a.triggerPosition();c[m?"height":"width"]=a.duration();f.css(g,c);f.css(n,{display:0<a.duration()?"":"none"})},u=function(){var c=x.trigger(b.colorTrigger),h={};h[m?"left":"bottom"]=0;h[m?"border-top-width":"border-left-width"]=
1;f.css(c.firstChild,h);f.css(c.firstChild.firstChild,{padding:m?"0 8px 3px 8px":"3px 4px"});document.body.appendChild(c);c={triggerHook:a.triggerHook(),element:c,members:[e]};d._indicators.groups.push(c);e.triggerGroup=c;d._indicators.updateTriggerGroupLabel(c);d._indicators.updateTriggerGroupPositions(c)}},x={start:function(a){var b=document.createElement("div");b.textContent="start";f.css(b,{position:"absolute",overflow:"visible","border-width":0,"border-style":"solid",color:a,"border-color":a});
a=document.createElement("div");f.css(a,{position:"absolute",overflow:"visible",width:0,height:0});a.appendChild(b);return a},end:function(a){var b=document.createElement("div");b.textContent="end";f.css(b,{position:"absolute",overflow:"visible","border-width":0,"border-style":"solid",color:a,"border-color":a});return b},bounds:function(){var a=document.createElement("div");f.css(a,{position:"absolute",overflow:"visible","white-space":"nowrap","pointer-events":"none","font-size":"11px","font-family":"sans-serif"});
a.style.zIndex="9999";return a},trigger:function(a){var b=document.createElement("div");b.textContent="trigger";f.css(b,{position:"relative"});var e=document.createElement("div");f.css(e,{position:"absolute",overflow:"visible","border-width":0,"border-style":"solid",color:a,"border-color":a});e.appendChild(b);a=document.createElement("div");f.css(a,{position:"fixed",overflow:"visible","white-space":"nowrap","pointer-events":"none","font-size":"11px","font-family":"sans-serif"});a.style.zIndex="9999";
a.appendChild(e);return a}};return{version:"1.0.0"}}console.error("ScrollMagic is not available.")}());