Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <div class="rocket__container">
  <div class="rocket">
    <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
      <path fill="#ff0" d="M899.612 408.384c40.944 28.294 83.226 58.678 109.44 101.926-25.564 42.646-67.094 72.732-107.312 100.622-99.508 65.694-219.030 105.858-339.156 97.756-17.796 21.23-34.882 43.074-53.042 63.988-27.594 30.022-70.638 44.040-110.654 36.812-50.55-10.072-101.214-19.752-151.626-30.412-25.936-5.926-37.81-41.016-21.24-61.646 28.582-34.242 58.216-67.632 86.834-101.864-24.924-25.9-41.544-60.306-43.546-96.428-2.932-41.582 14.312-82.75 42.484-112.896-18.802-24.56-41.372-47.332-61.51-71.328-9.32-11.598-21.568-21.242-27.932-34.968-9.13-21.28 4.496-48.684 27.37-53.494 49.284-10.958 98.48-22.406 147.84-33.040 41.756-8.642 87.22 6.664 115.214 38.838 15.644 18.626 30.974 37.512 46.192 56.486 2.78 5.286 9.192 2.63 13.902 2.93 115.902-5.656 230.464 33.934 326.742 96.718zM746.948 441.99c-31.988-24.848-81.536-21.842-110.104 6.976-33.618 30.51-34.844 88.3-2.58 120.212 22.506 24.634 60.292 32.964 91.342 21.206 29.934-10.774 52.39-39.618 55.182-71.342 3.372-29.296-10.106-59.63-33.84-77.052z"></path>
      <path fill="#ff0" d="M694.982 551.286c-22.988 0-41.624-18.636-41.624-41.624s18.636-41.624 41.624-41.624c22.988 0 41.624 18.636 41.624 41.624s-18.636 41.624-41.624 41.624z"></path>
      <path fill="#ff0" d="M208.362 396.526c14.532-0.426 24.524 17.66 16.834 29.884-26.64 51.74-26.628 116.054 0.014 167.792 7.29 11.874-1.466 29.472-15.606 29.91-30.864 0.174-61.76 0.21-92.634 0.048-15.066 0.238-24.674-19.664-15.252-31.362 7.852-8.904 16.682-16.934 24.922-25.5-26.402-13.552-53.204-26.326-79.544-39.99-12.55-6.562-12.636-27.066-0.21-33.754 26.39-13.74 53.352-26.426 79.716-40.242-8.314-8.442-17.096-16.496-24.936-25.388-9.468-11.648 0.324-31.512 15.294-31.35 30.458-0.248 60.93-0.086 91.402-0.048z"></path>
    </svg>
  </div>
  <div class="rocket__path">
    <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="800" height="600" viewBox="0 0 800 600">
      <path fill="none" stroke="#fff" stroke-dasharray="5,5" stroke-width="1" d="M34.0801507,267.834776 C57.974682,194.11212 146.341869,100.209776 225.919994,119.494933 C305.498119,138.780089 140.449731,368.368951 233.146557,416.381651 C325.002465,463.958795 716.373119,539.561339 595.025463,310.67462 C473.677807,81.7879014 376.877829,179.050345 344.060619,238.79962 C304.939526,310.026183 378.978588,439.780089 548.763744,416.381651 C718.548901,392.983214 778.107898,219.258188 722.302807,133.658995 C667.906727,50.2210786 515.205151,-15.7394423 382.271557,73.8972764 C275.690522,145.764545 102.599682,537.276183 309.169994,552.51837 C515.740307,567.760558 661.955151,592.701964 734.037182,514.436339 C833.310002,406.647349 718.929649,246.556666 614.759838,253.744933 C432.691368,266.308619 262.568432,561.885558 131.759838,552.51837 C70.420539,548.12587 8.02484412,348.224151 34.0801507,267.834776 Z"></path>
    </svg>
  </div>
</div>
              
            
!

CSS

              
                
body {
  background: #000;
}

.rocket {
  position: relative;
  width: 0;
  height: 0;

  > svg {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translate(0, -50%);
    width: 50px;
    height: auto;
    overflow: visible;
    
    path:last-of-type {
      transform-origin: 30% 50%;
    }
  }

  &__container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
  }
}
              
            
!

JS

              
                
var rocket = document.querySelector('.rocket')
var rocketContainer = document.querySelector('.rocket__container')
var rocketFlame = rocket.querySelector('svg path:last-of-type')
var rocketPath = document.querySelector('.rocket__path path')

var pointsArray = []
var points = rocketPath.getAttribute('d')
points = points.replace(/M|C|Z/g, '')
points = points.split(' ')

Array.prototype.forEach.call(points, function (point) {
  if (point.length > 0) {
    point = point.split(',')
    point = {
      x: point[0],
      y: point[1]
    }
    pointsArray.push(point)
  }
})

var rocketTween = TweenMax.to(rocket, 15, {
  bezier: {
    type: 'cubic',
    values: pointsArray,
    autoRotate: true
  },
  ease: Linear.easeNone,
  onComplete: function() {
    rocketTween.restart()
  }
})

var flameTween = new TimelineMax({ repeat: -1 })
flameTween.to(rocketFlame, .1, { scaleX: 1.5 }).to(rocketFlame, .1, { scaleX: 1 })

rocketContainer.addEventListener('click', function () {
  console.log('asdf')
  if (rocketTween.isActive()) {
    TweenMax.to([rocketTween, flameTween], .7, {
      timeScale: 0,
      ease: Power3.easeOut,
      onComplete: function() {
        rocketTween.pause()
      }
    })
  } else {
    rocketTween.play()
    TweenMax.to([rocketTween, flameTween], .7, {
      timeScale: 1,
      ease: Power2.easeIn
    })
  }
})

              
            
!
999px

Console