Pen Settings

HTML

CSS

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

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                .launch-control
  button.launch-control__button
    span(data-splitting='') Launch
  .launch-control__jets
    .jet.jet--one
    .jet.jet--two
    .jet.jet--three
  svg.rocket(xmlns='http://www.w3.org/2000/svg' viewBox='0 0 63.5 65.593')
    defs
      clipPath#rocket-clip
        rect#rocket-clip-rect(width='63.5' height='58.593' x='16.7083' fill='red' y='109.291')
    g(transform='translate(-16.7083 -109.291)' clip-path="url(#rocket-clip)")
      g.rocket__ship
        path.rocket__aux(d='M36.383 130.8587a2.8863 2.8863 0 00-2.8928 2.8927v22.9307h5.7859v-22.9307c0-1.6026-1.2905-2.8927-2.8931-2.8927z')
        path.rocket__aux-base(d='M33.4903 156.682h5.7858l1.1853 2.2577h-8.1565z')
        path.rocket__aux-shine(d='M36.3833 156.682v2.2577h4.078l-1.1852-2.2576z')
        path.rocket__aux(d='M60.5332 130.8587a2.8863 2.8863 0 00-2.8927 2.8927v22.9307h5.7858v-22.9307c0-1.6026-1.2905-2.8927-2.8931-2.8927z')
        path.rocket__aux-base(d='M57.6405 156.682h5.7858l1.1853 2.2577h-8.1564z')
        path.rocket__aux-shine(d='M60.5336 156.682v2.2577h4.078l-1.1853-2.2576z')
        path.rocket__wing(d='M33.1619 146.646c1.756-4.0332 8.8335-9.804 8.8335-9.804h12.9258s7.0774 5.7708 8.8335 9.804c1.1974 2.75.7902 8.9636.7902 8.9636H32.3717s-.4072-6.2135.7902-8.9636z')
        image.avatar(href='https://s3-us-west-2.amazonaws.com/s.cdpn.io/605876/bear-with-cap.svg' x='58' y='148' height='5' width='5')
        path.rocket__ship-body(d='M48.458 109.291c-4.201 0-7.583 8.5189-7.583 12.72v33.5987h15.1666V122.011c0-4.2011-3.3824-12.72-7.5835-12.72z')
        path.rocket__ship-shine(d='M48.4586 109.2912v46.3185h7.583v-33.5986c0-4.201-3.382-12.7194-7.583-12.72z')
        path.rocket__ship-tip(d='M48.4582 109.2912c-2.7205 0-5.0961 3.572-6.4337 7.2308h12.8673c-1.3377-3.6587-3.7132-7.2308-6.4336-7.2308z')
        rect.rocket__wing(width='1.9756' height='18.7677' x='47.4705' y='136.8419' ry='0')
        path.rocket__base(d='M42.8505 155.6096H54.066l1.9756 4.939H40.875z')
        path.rocket__windscreen(d='M44.0894 122.0853c.9012-.9715 2.5666-1.5699 4.3689-1.5699 1.8023 0 3.4677.5984 4.3688 1.5698' fill='none' stroke-width='1.5804' stroke-linecap='round' stroke-linejoin='round')
        g.rocket__face
          g.rocket__eyes
            circle.rocket__stroke(cx='44.7541' cy='130.0122' r='1.27' stroke='none' stroke-width='0')
            circle.rocket__pupil(cx='44.248' cy='129.6164' r='.3951')
            circle.rocket__stroke(r='1.27' cy='130.0122' cx='52.1624' stroke='none' stroke-width='0')
            circle.rocket__pupil(r='.3951' cy='129.6164' cx='51.6563')
          g.rocket__mouth
            path.rocket__stroke(d='M46.902 130.3855a1.5693 1.5693 0 00-.0132.1894 1.5693 1.5693 0 001.5693 1.5697 1.5693 1.5693 0 001.5696-1.5697 1.5693 1.5693 0 00-.0135-.1894z' stroke='none' stroke-width='0')
            path.rocket__tongue(d='M49.1569 131.1012a1.5693 1.5693 0 00-1.405.8736 1.5693 1.5693 0 00.7062.1698 1.5693 1.5693 0 001.4049-.8736 1.5693 1.5693 0 00-.7061-.1698z')
        g.rocket__face-takeoff
          path.rocket__stroke(d='M53.0702 131.112l-1.8204-1.0998 1.8204-1.0999' fill='none' stroke-width='.7902' stroke-linecap='round' stroke-linejoin='round')
          circle.rocket__stroke(r='.6713' cy='131.2651' cx='48.4583' stroke-width='0')
          path.rocket__stroke(d='M43.8464 131.112l1.8203-1.0998-1.8203-1.0999' fill='none' stroke-width='.7902' stroke-linecap='round' stroke-linejoin='round')
        path.rocket__base-shine(d='M48.4775 155.6097v4.9389h7.5642l-1.9756-4.9389z' fill='gray')
  .launch-control__bubbles
    - let c = 0
    while c < 10
      .launch-control__bubble.bubble(class=`bubble--${c}`)
      - c++
  svg.control-tower(xmlns='http://www.w3.org/2000/svg' viewBox='0 0 63.5 65.593')
    defs
      clipPath#body
        rect#rocket-clip-rect(width='63.5' height='58.593' x='16.7083' y='109.291')
    g(transform='translate(-16.7083 -109.291)' clip-path="url(#body)")
      g.control-tower__body
        path.launch-control__frame(d='M27.2143 169.244V138.25h7.7485v30.994z' fill='none' stroke-width='1.0583')
        path.launch-control__frame(d='M27.2143 169.244l7.7485-7.7485-7.7485-7.7485 7.7485-7.7485-7.7485-7.7485' fill='none' stroke-width='.7937')
        path.launch-control__frame(d='M34.9628 169.244l-7.7485-7.7485 7.7485-7.7485-7.7485-7.7485 7.7485-7.7485' fill='none' stroke-width='.7937')
        path.launch-control__frame(d='M53.1057 169.2452h9.2604v-18.5209h-9.2604z' fill='none' stroke-width='1.0583')
        path.launch-control__frame(d='M53.1057 169.2452l9.2604-9.2605-9.2604-9.2604' fill='none' stroke-width='.7937')
        path.launch-control__cable(d='M71.695 169.2452v-39.9698' fill='none'  stroke-width='.2646')
        path.launch-control__frame(d='M62.366 169.2452l-9.2603-9.2605 9.2604-9.2604' fill='none' stroke-width='.7937')
        path.launch-control__frame(d='M68.9555 169.2452v-51.8503h4.8109v51.8503z' fill='none' stroke-width='1.0583')
        path.launch-control__frame(d='M68.9555 169.2452l4.8109-4.8109-4.8109-4.8108 4.8109-4.8109-4.8109-4.8108 4.8109-4.8109-4.8109-4.8108 4.8109-4.8109-4.8109-4.8108 4.8109-4.8109' fill='none' stroke-width='.7937')
        path.launch-control__tower(stroke-width='.7937' stroke-linecap='round' stroke-linejoin='round' d='M68.8305 117.2626h5.061v12.0128h-5.061z')
        path.launch-control__walkway(d='M72.1636 125.413h-16.122' fill='none' stroke-width='.8869')
        path.launch-control__door(d='M70.0469 124.9695h.9909v-1.7915h-.9909z')
        path.launch-control__window(d='M68.4265 117.9294h5.869v2.6727h-5.869z')
    g(transform='translate(-16.7083 -109.291)')
      path.launch-control__hatch(d='M21.5217 169.2452h53.8731' stroke-width='3.1195')
  .launch-control__bubbles.launch-control__bubbles--two
    - let d = 0
    while d < 10
      .launch-control__bubble.bubble(class=`bubble--${10 + d}`)
      - d++
input#volume(type='checkbox')
label(for='volume', title='Toggle sound')
  //- On
  svg(viewBox="0 0 24 24")
    path(d="M14,3.23V5.29C16.89,6.15 19,8.83 19,12C19,15.17 16.89,17.84 14,18.7V20.77C18,19.86 21,16.28 21,12C21,7.72 18,4.14 14,3.23M16.5,12C16.5,10.23 15.5,8.71 14,7.97V16C15.5,15.29 16.5,13.76 16.5,12M3,9V15H7L12,20V4L7,9H3Z")
  //- Off
  svg(viewBox="0 0 24 24")
    path(d="M12,4L9.91,6.09L12,8.18M4.27,3L3,4.27L7.73,9H3V15H7L12,20V13.27L16.25,17.53C15.58,18.04 14.83,18.46 14,18.7V20.77C15.38,20.45 16.63,19.82 17.68,18.96L19.73,21L21,19.73L12,10.73M19,12C19,12.94 18.8,13.82 18.46,14.64L19.97,16.15C20.62,14.91 21,13.5 21,12C21,7.72 18,4.14 14,3.23V5.29C16.89,6.15 19,8.83 19,12M16.5,12C16.5,10.23 15.5,8.71 14,7.97V10.18L16.45,12.63C16.5,12.43 16.5,12.21 16.5,12Z")
              
            
!

CSS

              
                *
*:after
*:before
  box-sizing border-box
:root
  --frame hsl(355, 6%, 53%)
  --window hsl(184, 95%, 95%)
  --building hsl(180, 2%, 55%)
  --door hsl(200, 9%, 25%)
  --cable hsl(0, 0%, 0%)
  --walkway hsl(0, 0%, 75%)
  --stroke hsl(0, 0%, 10%)
  --pupil hsl(0, 0%, 100%)
  --tongue hsl(0, 100%, 50%)
  --aux hsl(355, 61%, 53%)
  --rocket-shine hsla(0, 0%, 100%, 0.85)
  --rocket-base hsl(0, 0%, 15%)
  --rocket-wing hsl(0, 0%, 35%)
  --rocket-body hsl(0, 0%, 80%)
  --hatch hsl(0, 0%, 20%)

body
  align-items center
  display flex
  justify-content center
  min-height 100vh
  background hsl(240, 41%, 50%)

.char
  display inline-block

.rocket
  &__stroke
    fill var(--stroke)
    stroke var(--stroke)

  &__face-takeoff path
    fill none

  &__base-shine
    fill var(--rocket-shine)

  &__base
    fill var(--rocket-base)
  &__windscreen
    stroke var(--rocket-base)

  &__wing
    fill var(--rocket-wing)

  &__ship
    &-tip
      fill var(--rocket-base)
    &-body
      fill var(--rocket-body)
    &-shine
      fill var(--rocket-shine)

  &__aux
    fill var(--aux)

    &-shine
      fill var(--rocket-shine)
    &-base
      fill var(--rocket-base)

  &__pupil
    fill var(--pupil)

  &__tongue
    fill var(--tongue)


.launch-control
  width 240px
  height 100px
  position absolute
  top 50%
  left 50%
  transform translate(-50%, -50%) scale(0.5)

  &__window
    fill var(--window)

  &__door
    fill var(--door)

  &__walkway
    stroke var(--walkway)

  &__cable
    stroke var(--cable)

  &__hatch
    stroke var(--hatch)

  &__frame
  &__tower
    stroke var(--frame)

  &__tower
    fill var(--building)

  &__button
    position absolute
    top 0
    left 0
    height 100%
    width 100%
    background 'hsl(%s, 65%, %s)' % (var(--h, 115) calc(var(--l, 50) * 1%))
    color hsl(0, 0%, 100%)
    font-weight bold
    outline transparent
    font-size 2rem
    font-family sans-serif
    cursor pointer
    border-radius 6px
    padding 0
    border 0
    margin 0
    box-shadow '1px 4px 10px 0 hsla(%s, 53%, 6%, 0.5)' % var(--h, 116)

    &:hover
      --l 60

    &:active
      --l 40

.rocket
.control-tower
  width 100%
  position absolute
  bottom 0
  display none

.launch-control__jets
.launch-control__bubbles
  position absolute
  height 100%
  width 100%
  display none

.jet
  background hsla(23, 94%, 54%, 0.75)
  position absolute
  bottom 24%

  &--one
  &--three
    width 8%
    height 38%
  &--one
    left 27%
  &--three
    right 27%
  &--two
    left 50%
    width 20%
    height 38%

.launch-control__bubbles--two
  transform rotateY(180deg)

.bubble
  position absolute
  left calc(var(--x, 50) * 1%)
  bottom 24%
  border-radius 50%
  background 'hsl(0, 0%, %s)' % calc(var(--l, 80) * 1%)
  height calc(var(--s, 10) * 1px)
  width calc(var(--s, 10) * 1px)

  &--0
  &--10
    --s 60
    --l 94
    --x 0
  &--1
  &--11
    --s 40
    --l 85
    --x 15
  &--2
  &--12
    --s 38
    --l 98
    --x 24
  &--3
  &--13
    --s 28
    --l 80
    --x 32
  &--4
  &--14
    --s 32
    --l 98
    --x 36
  &--5
  &--15
    --s 40
    --l 86
    --x 42
  &--6
  &--16
    --s 29
    --l 93
    --x 50
  &--7
  &--17
    --s 35
    --l 87
    --x 56
  &--8
  &--18
    --s 40
    --l 98
    --x 65
  &--9
  &--19
    --s 60
    --l 89
    --x 72

label
  height 44px
  width 44px
  position fixed
  bottom 1rem
  right 1rem
  cursor pointer

  & > svg
    position absolute
    height 100%
    width 100%
    top 0
    left 0

  path
    fill hsl(297, 63%, 67%)

  svg:nth-of-type(1)
    display none

[type='checkbox']
  // opacity 0
  height 0
  width 0

:checked ~ label
  svg:nth-of-type(1)
    display block
  svg:nth-of-type(2)
    display none
              
            
!

JS

              
                const {
  gsap: {
    timeline,
    set,
    delayedCall,
    to,
    utils: { random },
  },
  Splitting,
} = window

const SOUNDS = {
  ALARM: new Audio(
    'https://s3-us-west-2.amazonaws.com/s.cdpn.io/605876/alarm-trimmed.mp3'
  ),
  SCREAM: new Audio(
    ''
  ),
  OPEN: new Audio(
    'https://s3-us-west-2.amazonaws.com/s.cdpn.io/605876/garage-door-opening.mp3'
  ),
  CLOSE: new Audio(
    'https://s3-us-west-2.amazonaws.com/s.cdpn.io/605876/garage-door-closing.mp3'
  ),
  THRUSTERS: new Audio(
    'https://s3-us-west-2.amazonaws.com/s.cdpn.io/605876/rocket-thrusters-trimmed.mp3'
  ),
}

SOUNDS.ALARM.muted = SOUNDS.SCREAM.muted = SOUNDS.CLOSE.muted = SOUNDS.OPEN.muted = SOUNDS.CLOSE.muted = SOUNDS.THRUSTERS.muted = true

const toggleAudio = () => {
  SOUNDS.ALARM.muted = SOUNDS.SCREAM.muted = SOUNDS.CLOSE.muted = SOUNDS.OPEN.muted = SOUNDS.CLOSE.muted = SOUNDS.THRUSTERS.muted = !SOUNDS
    .THRUSTERS.muted
}

document.querySelector('#volume').addEventListener('input', toggleAudio)

Splitting()

const LAUNCH_BTN = document.querySelector('.launch-control__button')
// let LAUNCH_TL

set('.bubble', { transformOrigin: '50% 100%', scale: 0, opacity: 0 })

const BUBBLE_TL = timeline({ paused: true })
document.querySelectorAll('.bubble').forEach(bubble =>
  BUBBLE_TL.to(bubble, {
    scale: 1,
    duration: 'random(0.15, 0.5)',
    delay: () => Math.random() * -1,
    repeat: -1,
    yoyo: true,
  })
)
// BUBBLE_TL.play()
const getJets = () => {
  return timeline({
    onStart: () => {
      delayedCall(1, () => {
        SOUNDS.THRUSTERS.playbackRate = 1
        SOUNDS.THRUSTERS.play()
      })
    },
  })
    .to(
      '.jet',
      {
        delay: 1,
        scaleY: 1,
        duration: 0.1,
      },
      0
    )
    .to(
      '.bubble',
      {
        delay: 1,
        opacity: 1,
        duration: 0.1,
        onStart: () => {
          BUBBLE_TL.timeScale(0.75)
          BUBBLE_TL.play()
          delayedCall(1, () => BUBBLE_TL.timeScale(2))
          delayedCall(4, () => BUBBLE_TL.timeScale(0.5))
        },
      },
      0
    )
}
const getTakeoff = (s, d) =>
  timeline({
    onStart: () => {
      delayedCall(0.6, () => {
        set('.rocket__face', { display: 'none' })
        set('.rocket__face-takeoff', { display: 'block' })
      })
    },
  })
    .set('.jet', { transformOrigin: '50% 100%' })
    .to('.rocket', { x: 1, y: 1, repeat: 29, yoyo: true, duration: 0.05 })
    .to(
      '.rocket',
      {
        duration: s,
        ease: 'power4.in',
        y: `-=${d}`,
      },
      0
    )
    .to(
      '.jet',
      {
        duration: s,
        ease: 'power4.in',
        scaleY: (index, self) => {
          return d / self.offsetHeight + 1
        },
      },
      0
    )
set('.avatar', { transformOrigin: '50% 50%', rotate: -28})
set('.control-tower__body', { y: '+=100%' })
set('.jet--two', { x: '-=50%' })
set('.rocket__face-takeoff', { display: 'none' })
const RESET = () => {
  LAUNCH_BTN.removeAttribute('disabled')
  set(SOUNDS.THRUSTERS, { volume: 1 })
  set(
    [
      '.rocket',
      '.control-tower',
      '.launch-control__jets',
      '.launch-control__bubbles',
      '.rocket__face-takeoff',
    ],
    { display: 'none' }
  )
  set('.rocket__face', { display: 'block' })
  set(['.rocket'], { y: 0 })
  set(['.rocket__ship'], { y: '+=100%' })
  set('.launch-control__hatch', { scaleX: 0, transformOrigin: '50% 50%' })
  set('.jet', { transformOrigin: '50% 0', scaleY: 0, opacity: 1 })
  set('.bubble', { scale: 0 })
}
// Start small
set('.launch-control', { scale: 0.5 })
RESET()
const PPS = 150
const LAUNCH = () => {
  LAUNCH_BTN.setAttribute('disabled', true)
  const DISTANCE = window.innerHeight * 0.6
  const SPEED = DISTANCE / PPS
  set(
    [
      '.rocket',
      '.control-tower',
      '.launch-control__bubbles',
      '.launch-control__jets',
    ],
    { display: 'block' }
  )
  timeline({
    onComplete: RESET,
    onStart: () => {
      set(LAUNCH_BTN, { '--h': 0 })
    },
  })
    .to('.launch-control', {
      onStart: () => {
        SOUNDS.ALARM.play()
      },
      scale: 1,
      duration: 0.5,
    })
    .fromTo(
      LAUNCH_BTN,
      { '--l': 50 },
      {
        '--l': 100,
        duration: 0.9,
        repeat: 4,
        yoyo: true,
      },
      0.5
    )
    .to(
      '.char',
      {
        onStart: () => SOUNDS.SCREAM.play(),
        duration: () => random(0.5, 1),
        // delay: Math.random(),
        x: () => random(-100, 100),
        y: () => random(100, 120),
        scale: () => random(1, 1.5),
        // opacity: 0,
      },
      0.5
    )
    .to(
      '.char',
      {
        duration: 0.1,
        opacity: 0,
      },
      '>-0.5'
    )
    .to('.launch-control__hatch', {
      duration: 5,
      scaleX: 1,
      onStart: () => {
        SOUNDS.OPEN.playbackRate = 2.6
        SOUNDS.OPEN.play()
      },
    })
    .to(['.control-tower__body', '.rocket__ship'], {
      ease: 'none',
      duration: 2,
      y: 0,
    })
    .to(
      '.rocket__eyes',
      {
        scaleY: 0,
        repeat: 1,
        yoyo: true,
        transformOrigin: '50% 50%',
        duration: 0.05,
      },
      '<2'
    )
    // // Jets firing and smoke blah
    .add(getJets())
    .add(getTakeoff(SPEED, DISTANCE))
    .to(['.jet', '.bubble'], {
      delay: 0.5,
      duration: 1,
      opacity: 0,
      onComplete: () => {
        to(SOUNDS.THRUSTERS, { delay: 0.5, duration: 1, volume: 0 })
        BUBBLE_TL.pause()
      },
    })
    .to('.control-tower__body', { duration: 2, y: '+=100%' })
    .to('.launch-control__hatch', {
      onStart: () => {
        SOUNDS.CLOSE.playbackRate = 2.6
        SOUNDS.CLOSE.play()
      },
      duration: 5,
      scaleX: 0,
    })
    .set('.char', { x: 0, y: 0, scale: 1 })
    .set(LAUNCH_BTN, { '--h': 115 })
    .to('.launch-control', {
      onStart: () => {
        set('.rocket', { display: 'none' })
      },
      delay: 0.5,
      scale: 0.5,
      duration: 1,
    })
    .to(LAUNCH_BTN, { '--l': 50, duration: 0.2 })
    .to('.char', { opacity: 1, duration: 0.5 })
}

LAUNCH_BTN.addEventListener('click', LAUNCH)

              
            
!
999px

Console