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.

              <div id="app">
    <div class="button-group">
      <button @click="animateBall" v-if="!running">Start</button>
      <button @click="cancelAnimate" v-else>Reset</button>
      <height-counter @heightincrease="incrementHeight"></height-counter>
      <radius-counter @radiusincrease="incrementRadius"></radius-counter>
    <svg xmlns="" viewBox="0 0 1200 600" class="bounce">
      <line x1="600" x2="600" y1="0" :y2="total+radius" stroke="#555" stroke-width="2" stroke-dasharray="5, 5"/>
      <line x1="590" x2="610" y1="1" y2="1" stroke="#555" stroke-width="2"/>
      <line x1="590" x2="610" :y1="total+radius" :y2="total+radius" stroke="#555" stroke-width="2"/>
      <circle :style="{ transform: `translate3d(${x1}px, ${y1}px, 0)` }" :r="radius" :cx="radius" :cy="radius" fill="teal"/>

<script type="text/x-template" id="height-counter">
 <button @click="heightincrease">Increase height</button>

<script type="text/x-template" id="radius-counter">
 <button @click="radiusincrease">Increase radius</button>

              body {
  background: #222;

.bounce {
  width: 100vw;
  height: 80vh;

.button-group {
  width: 400px;
  margin: 20px auto;
  button {
    font-family: 'Montserrat', sans-serif;
    min-width: 80px;
    border: none;
    padding: 8px 16px;
    background: #444;
    color: white;
    border-radius: 3px;
    outline: 0;
    cursor: pointer;
              Vue.component("height-counter", {
  template: "#height-counter",
  data() {
    return {
      count: 3
  methods: {
    heightincrease: function () {
      this.count += 1

Vue.component("radius-counter", {
  template: "#radius-counter",
  data() {
    return {
      countR: 0
  methods: {
    radiusincrease: function () {
      this.countR += 3

new Vue({
  el: '#app',
  data: {
    total: 200,
    radius: 15,
    x1: 15,
    y1: 15,
    g: 0.1,
    vx: 2.5,
    vy: 0,
    req: undefined,
    running: false
  methods: {
    incrementHeight() { += 100
    incrementRadius() {
      this.radius += 1
    bounceBall() {   
      this.vy += this.g; // gravity increases the vertical speed
      this.x1 += this.vx; // horizontal speed inccrements horizontal position 
      this.y1 += this.vy; // vertical speed increases vertical position

      if (this.y1 > - this.radius) { // if ball hits the ground
        this.y1 = - this.radius; // reposition it at the ground
        this.vy *= -0.8; // then reverse and reduce its speed
    animateBall() {
      //use rAF to animate but put a boundary on it so it doesn't run forever
      let start,
          vueThis = this;
      this.running = true;
      function step(timestamp) {
        if (!start) start = timestamp;
        var progress = timestamp - start;
        if (progress < 13000) {
          vueThis.req = window.requestAnimationFrame(step);
        } else {
          vueThis.x1 = this.radius;
          vueThis.y1 = this.radius;
          vueThis.running = false;
      this.req = window.requestAnimationFrame(step);
    cancelAnimate() {
      this.running = false;
      this.radius = 15;
      this.x1 = this.radius;
      this.y1 = this.radius; = 200;
      this.g = 0.1;
      this.vx = 2;
      this.vy = 0;

🕑 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.