diff --git a/HypeDynamicCamera.min.js b/HypeDynamicCamera.min.js new file mode 100644 index 0000000..7c8364c --- /dev/null +++ b/HypeDynamicCamera.min.js @@ -0,0 +1,9 @@ +/* + Hype Dynamic Camera 1.2.1 +copyright (c) 2015 by Lucky (Tumult Forum @Luckyde) +maintaind since 2018 by Max Ziebell, (https://maxziebell.de). MIT-license +*/ +!1==="HypeDynamicCamera"in window&&(window.HypeDynamicCamera=function(){var e={};!1==="HYPE_eventListeners"in window&&(window.HYPE_eventListeners=[]);window.HYPE_eventListeners.push({type:"HypeDocumentLoad",callback:function(b,q,r){b.setupDynamicCamera=function(a,c,h){if(e[a.id])console.log("restart"),e[a.id].observe(a,{attributes:!0,attributeFilter:["style"]});else{var d=document.getElementById(b.currentSceneId());a&&"string"==typeof a&&(a=d.querySelector(a));c&&"string"==typeof c&&(c=d.querySelector(c)); +if((c=c||d)&&a){h=h||{};var t=b.getElementProperty(d,"width"),u=b.getElementProperty(d,"height"),G=180/Math.PI,k,v,w,l,m,x,y,z,A,B,n,p,C,D,f,g,E,F;h.showCamera||(a.style.visibility="hidden",a.style.zIndex=d.style.zIndex);e[a.id]=new MutationObserver(function(H){k=new WebKitCSSMatrix(window.getComputedStyle(a).webkitTransform);A=b.getElementProperty(a,"left");B=b.getElementProperty(a,"top");n=b.getElementProperty(a,"height");p=b.getElementProperty(a,"width");C=b.getElementProperty(a,"scaleX");D=b.getElementProperty(a, +"scaleY");z=-Math.atan2(k.b,k.a)*G;f=p*C;g=n*D;E=A-(f-p)/2;F=B-(g-n)/2;l=E+f/2;m=F+g/2;x=-1*(l-t/2);y=-1*(m-u/2);v=t/f;w=u/g;c.style.transformOrigin=c.style.WebkitTransformOrigin=l+"px "+m+"px";c.style.webkitTransform=c.style.transform="translateX("+x+"px) translateY("+y+"px) scaleX("+v+") scaleY("+w+") rotateZ("+z+"deg)";c.style.webkitFilter=a.style.webkitFilter;c.style.opacity=a.style.opacity});e[a.id].observe(a,{attributes:!0,attributeFilter:["style"]})}}}}});window.HYPE_eventListeners.push({type:"HypeSceneLoad", +callback:function(b,q,r){document.getElementById(b.currentSceneId()).querySelectorAll("[data-dynamic-camera]").forEach(function(a){var c=a.getAttribute("data-dynamic-camera");b.setupDynamicCamera(a,c)})}});window.HYPE_eventListeners.push({type:"HypeSceneUnload",callback:function(b,q,r){Object.values(e).forEach(function(a){a.disconnect()})}});return{version:"1.2.1"}}());