cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div id="bodymovin"></div>

<footer class="footer v-dark">
 Made with 🍻  by <a class="footer-anchor" target="_blank" href="https://twitter.com/jorisvanr">Joris</a> &<a class="footer-anchor" target="_blank" href="https://twitter.com/ryan_schuijer">Ryan</a>
</footer>
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Roboto');

$black: #343436;
$white: #fff;
$yellow: #fcd000;

*, *:before, *:after {
 margin: 0;
 padding: 0;
 box-sizing: border-box;
}


body,
html {
  background-color: #F2E297;
  margin: 0px;
  height: 100%;
  overflow: hidden;
}

#bodymovin {
  background-color: #F2E297;
  width: 100%;
  height: 100%;
  display: block;
  transform: translate3d(0, 0, 0);
  margin: auto;
}

.footer {
 position: fixed;
 right: 0;
 bottom: 0;
 left: 0;
 padding: 10px 10px;
 text-align: right;
 font-family: 'Roboto', sans-serif;
 font-size: 12px;
 
 &.v-dark {
  background-color: $black;
  color: $white;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
 }
 &.v-light {
  background-color: $white;
  color: $black;
 }
}

.footer-anchor {
 display: inline-block;
 margin-left: 5px;
 padding: 2px 4px;
 color: $black;
 text-decoration: none;
 background-color: $yellow;
 border-radius: 4px;
 opacity: 1;
 transition: opacity 0.2s;
 
 &:hover {
  opacity: 0.6;
 }
}
            
          
!
            
              var anim;
    var elem = document.getElementById('bodymovin')
    var animationParams = {
        container: elem,
        renderer: 'html',
        loop: true,
        autoplay: true,
        rendererSettings: {
        progressiveLoad:false,
        preserveAspectRatio:'xMaxYMax'
        },
        animationData: animData
    };
    anim = bodymovin.loadAnimation(animationParams);
    var lockeds = {
        2: false,
        3: false,
        4: false,
        5: false
    }
    var currentLayerNum = -1;
    var currentPos = [500.5, 400, -2666.667];
    var mousePos = [500.5, 400, -2666.667];

    function moveCamera(){
        currentPos[0] = currentPos[0] + (mousePos[0] - currentPos[0])*0.25;
        currentPos[1] = currentPos[1] + (mousePos[1] - currentPos[1])*0.25;
        currentPos[2] = currentPos[2] + (mousePos[2] - currentPos[2])*0.25;
        anim.animationData.layers[0].ks.p.k[0].s[0] = currentPos[0];
        anim.animationData.layers[0].ks.p.k[0].e[0] = currentPos[0];
        anim.animationData.layers[0].ks.p.k[0].s[1] = currentPos[1];
        anim.animationData.layers[0].ks.p.k[0].e[1] = currentPos[1];
        anim.animationData.layers[0].ks.p.k[0].s[2] = currentPos[2];
        anim.animationData.layers[0].ks.p.k[0].e[2] = currentPos[2];
        requestAnimationFrame(moveCamera);
    }

    anim.addEventListener('DOMLoaded', function(){

        moveCamera();

        window.addEventListener('mousemove', function(ev){
            
            mouseCoords.x = ev.clientX || ev.pageX;
            mouseCoords.y = ev.clientY || ev.pageY;
            theta = Math.atan2(
                windowH/2 - mouseCoords.y,
                windowW/2 - mouseCoords.x
            );
            var layerNum = 0;
            if(theta <= Math.PI && theta > Math.PI/2){
                layerNum = 2;
            } else if(theta <= Math.PI/2 && theta > 0){
                layerNum = 3;
            } else if(theta <= 0 && theta > -Math.PI/2){
                layerNum = 4;
            } else{
                layerNum = 5;
            }

            dist = Math.sqrt(Math.pow(mouseCoords.x - windowW/2, 2) + Math.pow(mouseCoords.y - windowH/2, 2));
            mousePos[0] = 500.5 + Math.cos(theta)*dist;
            mousePos[1] = 400 + Math.sin(theta)*dist;
        })

        
    })

    var windowW, windowH, dist;
    var mouseCoords = {
        x:0,
        y:0
    }
    function calculateSize(){
        windowW = window.innerWidth;
        windowH = window.innerHeight;
    }

    window.addEventListener('resize', function(){
        calculateSize();
        anim.resize();
    })
    calculateSize();
            
          
!
999px
Loading ..................

Console