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.

            
              <!-- Click the switch to power him up! -->

<div  id="anim_container"></div>


            
          
!
            
              body,
html {
  margin:0;
  padding:0;
  width: 100%;
  height: 100%;
  background-color: #399AE7;
}


#anim_container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width:70%;
  max-width:1200px;


}

#switch {
 cursor: pointer;
}

.flick--on{
   -webkit-transform: rotate(180deg);
  -ms-transform: rotate(180deg);
  transform: rotate(180deg);
  -webkit-transform-origin:center !important;
  -ms-transform-origin:center !important;
   transform-origin:center !important;

 cursor: pointer;

}

.flick--off {

  -webkit-transform: rotate(0deg);
  -ms-transform: rotate(0deg);
  transform: rotate(0deg);
  -webkit-transform-origin:center !important;
  -ms-transform-origin:center !important;
      transform-origin:center !important;

 cursor: pointer;
}

.arrowpointer {
  cursor: default !important;
}
            
          
!
            
              
// bodymovin.js settings

   var animation = {

        wrapper: document.getElementById('anim_container'),
        animType: 'svg',
        loop: true,
        prerender: true,
        autoplay: true,
        animationData: mixer

   };

  var anim = bodymovin.loadAnimation(animation);

// Start the PowerOff animation loop

  powerOff()


// Define the sections of the animation:

  function powerOff() {
    anim.playSegments([[0,60],[0,60]],true);

    anim.removeEventListener('loopComplete',powerOff);

   }


  function powerUp() {

    anim.removeEventListener('loopComplete',powerUp);
    anim.addEventListener('loopComplete',powerOn);
    anim.playSegments([[60,67]],true);

}

  function powerOn() {
   
    anim.playSegments([[67,117]],true);
    console.log('powerOn');
    anim.removeEventListener('loopComplete',powerOn);

}


 function powerDown() {

    anim.playSegments([[117,139]],true);
    anim.removeEventListener('loopComplete',powerOn);
    anim.removeEventListener('loopComplete',powerDown);     
    anim.addEventListener('loopComplete',powerOff);

 }

 // On and off switch: 1 is on, 2 is off

  setTimeout(function() {
    $("#switch").one("click", switchTrigger);
  }, 1000);

  var switchFlag = 1;

  function switchTrigger() {

  $('#switch').addClass('arrowpointer');


    setTimeout(function() {
      $("#switch").removeClass('arrowpointer').one("click", switchTrigger);

    }, 1000);


   if ( switchFlag == 1 ) {
      
     // Flip the switch illustration between up and down
     
      $( "#switch" ).addClass("flick--on");
      $( "#switch" ).removeClass("flick--off");

      anim.removeEventListener('loopComplete',powerOff);
      anim.addEventListener('loopComplete',powerUp);
          
        switchFlag = 2;

    } else {
      
      // Flip the switch illustration between up and down

      $( "#switch" ).addClass("flick--off");
      $( "#switch" ).removeClass("flick--on");


      anim.addEventListener('loopComplete',powerDown);

      switchFlag = 1;
    }
}


            
          
!
999px
Loading ..................

Console