123

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              .title
  h2 STARGATE
  h4 #[a(href="https://twitter.com/Manz") BY @MANZ]
.sg-border
  - for (i=1; i<10; i++)
    .arrow(class="arrow"+i)
  #stargate
    .wormhole
      - for (i=1; i<40; i++)
        img.chevron(src="https://manzdev.github.io/cursos-assets/css3/svg/chevrons/"+ ("000" + i).substr(-3,3) +".svg")      
div.message
  p Press chevrons for call...
  p.small (WARNING: AUDIO LEVEL IS HIGH)
            
          
!
            
              @path: 'https://manzdev.github.io/cursos-assets/css3/';

// Prepare Stargate font
@font-face {
  font-family: 'Stargate';
  src: local('Stargate'),
       url('@{path}fonts/Stargate.ttf.woff') format('woff');
}

html, body {
  margin:0;
  background:#000;
  overflow:hidden;
  //background:#040404 url('@{path}bg.png');
}

// Title header
.title {
  width:600px;
  margin:0 auto 25px auto;
  padding:0 25px;
  font-family:'Stargate';
  
  img {
    filter:invert(1);
    width:64px;
  }

  h2 {
    font-size:82px;
    color:#FFF;
    margin:25px auto 0 auto;
    text-align:center;
  }

  h4 {
    text-align: right;
    margin: 0;
    padding: 10px 75px 0 0;
    border-top: 1px solid #ffa012;
    
    a {
      color:#0ea8ef;  
    }
  }
}

// Out border
.sg-border {
  width:675px;
  height:675px;
  border:14px solid #111;
  border-radius:50%;
  margin:auto;
  position:relative;
}

// Chevrons
.arrow {
  position:absolute;  
  z-index:2;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 25px 25px 0 25px;
  border-color: #5e2f12 transparent transparent transparent;
  transition:all 1s linear;
  
  &.on {
    border-color: orange transparent transparent transparent;
    filter:drop-shadow(0 0 5px red);
  }

  &.arrow1 {
    left:318px;
  }

  &.arrow2 {
    left:525px;
    top:80px;
    transform:rotate(40deg);
  }

  &.arrow3 {
    left:635px;
    top:300px;
    transform:rotate(87deg);
  }

  &.arrow4 {
    left:575px;
    top:515px;
    transform:rotate(125deg);  
  }

  &.arrow5 {
    left:425px;
    top:630px;
    transform:rotate(160deg);
  }

  &.arrow6 {
    left:215px;
    top:635px;
    transform:rotate(200deg);
  }

  &.arrow7 {
    left:50px;
    top:515px;
    transform:rotate(235deg);
  }

  &.arrow8 {
    left:-12px;
    top:315px;
    transform:rotate(272deg);
  }

  &.arrow9 {
    left:70px;
    top:105px;
    transform:rotate(310deg);
  }
}

// Stargate inner circle
#stargate {
  background:radial-gradient(transparent 53%, #222 53%);
  width:675px;
  height:675px;
  margin:auto;
  border-radius:50%;
  box-shadow:3px 3px 5px #000 inset,
             -4px -4px 6px #000 inset;
  display:flex;
  justify-content:center;
  align-items:center;
  animation:move 20s cubic-bezier(.44,.35,.78,.73) paused infinite; 
  
  &.on {
    animation-play-state:running;
  }
  
  img.chevron {
    filter:invert(1);
    width:42px;
    position:absolute;
    top:46%;
    left:47%;  
  }
  
  // Primer cuadrante
  .chevron:nth-child(1)  { transform: translate(0,     -300px) } 
  .chevron:nth-child(2)  { transform: translate(50px,  -290px) } 
  .chevron:nth-child(3)  { transform: translate(100px, -275px) } 
  .chevron:nth-child(4)  { transform: translate(145px, -250px) }
  .chevron:nth-child(5)  { transform: translate(185px, -225px) }
  .chevron:nth-child(6)  { transform: translate(220px, -185px) }
  .chevron:nth-child(7)  { transform: translate(250px, -140px) }
  .chevron:nth-child(8)  { transform: translate(275px,  -90px) }
  .chevron:nth-child(9)  { transform: translate(285px,  -40px) }
  .chevron:nth-child(10) { transform: translate(290px,      0) }

  // Segundo cuadrante
  .chevron:nth-child(11) { transform: translate(288px,   50px) }
  .chevron:nth-child(12) { transform: translate(275px,   95px) }
  .chevron:nth-child(13)  { transform: translate(253px,  135px) } 
  .chevron:nth-child(14)  { transform: translate(230px,  172px) } 
  .chevron:nth-child(15)  { transform: translate(197px,  207px) }
  .chevron:nth-child(16)  { transform: translate(153px,  243px) }
  .chevron:nth-child(17)  { transform: translate(111px,  269px) }
  .chevron:nth-child(18)  { transform: translate(70px,   286px) }
  .chevron:nth-child(19)  { transform: translate(21px,   293px) } 
  .chevron:nth-child(20)  { transform: translate(-25px,  295px) }

  // Tercer cuadrante
  .chevron:nth-child(21)  { transform: translate(-66px,  290px) }
  .chevron:nth-child(22)  { transform: translate(-109px, 277px) }
  .chevron:nth-child(23)  { transform: translate(-144px, 258px) }
  .chevron:nth-child(24)  { transform: translate(-185px, 235px) }
  .chevron:nth-child(25)  { transform: translate(-221px, 202px) }
  .chevron:nth-child(26)  { transform: translate(-249px, 170px) }
  .chevron:nth-child(27)  { transform: translate(-272px, 135px) }
  .chevron:nth-child(28)  { transform: translate(-282px, 100px) }
  .chevron:nth-child(29)  { transform: translate(-295px, 69px) }
  .chevron:nth-child(30)  { transform: translate(-300px, 32px) }
  .chevron:nth-child(31)  { transform: translate(-300px, -17px) }

  // Cuarto cuadrante
  .chevron:nth-child(32)  { transform: translate(-293px, -61px) }
  .chevron:nth-child(33)  { transform: translate(-282px, -103px) }
  .chevron:nth-child(34)  { transform: translate(-263px, -138px) }
  .chevron:nth-child(35)  { transform: translate(-240px, -171px) }
  .chevron:nth-child(36)  { transform: translate(-205px, -211px) }
  .chevron:nth-child(37)  { transform: translate(-163px, -248px) }
  .chevron:nth-child(38)  { transform: translate(-109px, -275px) }
  .chevron:nth-child(39)  { transform: translate(-60px,  -287px) }   
}

// Stargate wormhole
.wormhole {
  position:relative;
  background-color:transparent; //#000;
  box-shadow:0 0 15px 10px RGBA(0,0,0, .5);
  border:#000 1px solid;
  width:510px;
  height:510px;
  border-radius:50%;
  transition:all 1s ease;
  
  &.on {
    background-color:#22A;
    box-shadow:15px 15px 25px #11B inset,
               -15px -15px 45px #11A inset,
               0 0 15px 10px RGBA(0,0,0, .5);
    //animation: moveColor 2s ease-in-out alternate infinite;
  }
}

// Initial message
div.message {
  position:absolute;
  font-size:42px;
  color:#666;
  top:50vh;
  z-index:5;
  width:100%;
  text-align:center;
  animation:fadeout 1s ease-out 3s 1 forwards;
  background:RGBA(75,75,75, .25);
  
  & p:first-child {
    margin-bottom:0;
  }

  & .small {
    font-size:18px;
    margin-top:0;
    padding-bottom:20px;
  }
}

// Animations
@keyframes move {
  0% { transform:rotate(0) }
  100% { transform:rotate(360deg) }
}

@keyframes fadeout {
  0% { opacity:1; z-index:4 }
  100% { opacity:0; z-index:-1 }
}

/*
@keyframes moveColor {
  0% { background-color: #22A }
  100% { background-color: #2828AA }
}
*/
            
          
!
            
              // SVG: http://stargate.wikia.com/wiki/Glyph

var sounds = {}
//var path = 'https://cdn.rawgit.com/ManzDev/cursos-assets/gh-pages/css3/audio/';
var path = 'https://manzdev.github.io/cursos-assets/css3/audio/';
var title = document.querySelector('.title');
var listChevrons = document.querySelectorAll('#stargate img');

// ChevronClosed sounds
sounds.chevronClosed = {
  audio: [new Audio(path + 'chev_usual_1.mp3'),
          new Audio(path + 'chev_usual_2.mp3'),
          new Audio(path + 'chev_usual_3.mp3'),
          new Audio(path + 'chev_usual_4.mp3'),
          new Audio(path + 'chev_usual_5.mp3'),
          new Audio(path + 'chev_usual_6.mp3'),
          new Audio(path + 'chev_usual_7.mp3')]
}
sounds.chevronClosed.play = function(n = -1) {
  if (n == -1)
    var n = Math.floor(Math.random() * this.audio.length);
  this.audio[n].currentTime = 0;
  this.audio[n].play();
}

// Stargate sounds
sounds.gateRoll = new Audio(path + 'roll.mp3');
sounds.gateSpin = new Audio(path + 'spin.mp3');
sounds.fail = new Audio(path + 'fail.mp3');
sounds.gateClose = new Audio(path + 'eh_usual_close.mp3');
sounds.gateOpen = new Audio(path + 'eh_usual_open.mp3');
sounds.gateSpin.loop = true;
sounds.gateSpin.addEventListener('timeupdate', function() {
  if (this.currentTime > this.duration - .3)
    this.currentTime = 0;
});

// WormHole Loop sounds
sounds.wormHole = new Audio(path + 'wormhole.mp3');
sounds.wormHole.loop = true;
sounds.wormHole.addEventListener('timeupdate', function() {
  if (this.currentTime > this.duration - .6)
    this.currentTime = 0;
});

// Arrows
var arrows = document.querySelectorAll('.arrow');
[].forEach.call(arrows, function(i) {
  i.addEventListener('click', function() {
    
    if (!this.classList.contains('on')) {
      sounds.chevronClosed.play();
      this.classList.add('on');
      
      if (stargate.getChevronsOpened() == 8) {
        stargate.startMove();
        //stargate.title = title.innerHTML;
        //title.innerHTML = '';
      }
      
      //var n = Math.floor(Math.random() * listChevrons.length);
      //title.innerHTML += listChevrons[n].outerHTML;
    
      if ((stargate.isOpen() == false) && (stargate.isReady() == true))
        setTimeout(function() {
          stargate.enableWormHole();
        }, 1000);
    }
   
  });
});

var stargate = {
  
  CHAPAHAI_OPEN: false,
  
  isOpen: function() {
    return this.CHAPAHAI_OPEN;
  },
  
  isReady: function() {
    return (document.querySelectorAll('.arrow:not(.on)').length === 0);
  },
  
  getChevronsOpened: function() {
    return document.querySelectorAll('.arrow:not(.on)').length;
  },

  // Comienza a mover el Stargate (20 seg máx.)
  startMove: function() {
    document.querySelector('#stargate').classList.add('on'); 
    sounds.gateRoll.volume = .5;
    sounds.gateRoll.currentTime = 0;
    sounds.gateRoll.play();
    
    setTimeout(function() {
      document.querySelector('#stargate').classList.remove('on');
      
      if (stargate.isOpen() == false) {
        sounds.fail.play();
        stargate.disableChevrons();
      }
    }, 20000);
  },
  
  stopMove: function() {
    document.querySelector('#stargate').classList.remove('on');
    if (!sounds.gateRoll.paused)
      sounds.gateRoll.pause()
  },
  
  // Activa un chevron aleatorio (o el "n" indicado)
  enableChevron: function(n = -1) {
    var arrowsOff = document.querySelectorAll('.arrow:not(.on)');
    if (n == -1)
      var n = Math.floor(Math.random() * arrowsOff.length);
    
    arrowsOff[n].classList.add('on');
    sounds.chevronClosed.play();
  },
  
  disableChevrons: function() {
    [].forEach.call(arrows, function(i) {
      i.classList.remove('on');
    });
  },
  
  enableWormHole: function() {
    this.CHAPAHAI_OPEN = true;
    this.stopMove();    
    sounds.gateOpen.play();
    document.querySelector('.wormhole').classList.add('on');
    setTimeout(function() { 
      sounds.wormHole.play();
    }, 3000);
    
    setTimeout(function() {
      stargate.disableWormHole();
    }, 18000);
  },
  
  disableWormHole: function() {
    this.CHAPAHAI_OPEN = false;
    sounds.gateClose.play();
    setTimeout(function() {
      document.querySelector('.wormhole').classList.remove('on');
      sounds.wormHole.pause();      
    }, 300);
    this.disableChevrons();
    //title.innerHTML = stargate.title;
  }
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console