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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              <main id="app" class="chart">
  <figure class="chart__content">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="-20 -25 440 125">
      <path class="chart__path" :d="`M${path}`"
        fill="none" stroke="rgba(255, 255, 255, 0.3)"
        stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
      
      <text v-for="([ x, y ]) in path" :x="x - 10" :y="y - 7.5"
        font-size="11" font-weight="200" fill="currentColor">
        {{ 100 - (y | 0) + '%' }}
      </text>
    </svg>
    
    <figcaption class="chart__caption">
      <h1 class="chart__title">SVG path animation</h1>
      <h2 class="chart__subtitle">with VueJS &amp; TweenLite</h2>
    </figcaption>
  </figure>
  
  <button class="modal__open" @click="modal = true">About this pen</button>
  
  <transition name="modal">
    <section v-if="modal" class="modal" @click="modal = false">
      <article class="modal__content" @click.stop>
        <h4 class="modal__title">For the full tutorial</h4>
        <h4 class="modal__title">that goes with this pen</h4>

        <h5 class="modal__link" @click="modal = false">
          <a href="https://snipcart.com/blog/vuejs-transitions-animations" target="_blank">
            Creating Vue.js Transitions &amp; Animations
          </a>
        </h5>

        <button class="modal__close" @click="modal = false">&times;</button>
      </article>
    </section>
  </transition>
</main>

            
          
!
            
              .chart {
  height: 100vh;
  display: flex;
  color: #36424b;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(rgb(192, 241, 149), rgb(76, 155, 149));
  
  &__content {
    width: 95%;
    max-width: 775px;
    padding-right: 1.5rem;
    position: relative;
    
    &::before,
    &::after {
      content: '';
      position: absolute;
      bottom: 0;
      left: 0;
    }
    
    &::before {
      width: 100%;
      height: 1px;
      background: linear-gradient(to right, rgba(black, 0.3), rgba(black, 0) 110%);
    }
    
    &::after {
      width: 1px;
      height: 100%;
      background: linear-gradient(to top, rgba(black, 0.3), rgba(black, 0) 110%);
    }
    
    svg {
      display: block;
    }
  }
  
  &__caption {
    left: 50%;
    top: 100%;
    width: 100%;
    position: absolute;
    text-align: center;
    transform: translate(-50%, 100%);
  }
  
  &__title {
    font-size: 1.3rem;
  }
  
  &__subtitle {
    font-size: 1.15rem;
    margin-top: 0.5em;
  }
}

.modal {
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(white, 0.6);
  z-index: 1;

  &-enter-active,
  &-leave-active { transition: opacity 350ms }

  &-enter,
  &-leave-to { opacity: 0 }

  &-leave,
  &-enter-to { opacity: 1 }
  
  &__open {
    position: fixed;
    top: 2em;
    right: 2.5rem;
    font-weight: 200;
    font-size: 1.1rem;
  }

  &__content {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 90%;
    max-width: 500px;
    min-height: 250px;
    padding: 1.5rem 1rem;
    background-color: white;
    border: 1px solid #c5d0d1;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 0.5rem 1.75rem -0.25rem rgba(#3d5358, 0.4);
  }

  &__title {
    font-size: 1.5rem;
  }

  &__link {
    margin-top: 1.5rem;
    position: relative;
    font-size: 1.2rem;
    font-weight: 300;
    z-index: 0;

    &::after {
      content: '';
      width: 100%;
      height: 1px;
      position: absolute;
      bottom: 0;
      left: 0;
      background-color: currentColor;
      z-index: -1;
      transition: background-color 225ms ease-out;
    }

    &:hover::after {
      background-color: rgb(76, 155, 149);
    }
  }

  &__close {
    position: absolute;
    top: 0.25rem;
    right: 1rem;
    font-size: 2.5rem;
    opacity: 0.5;
    line-height: 1;
    transition: opacity 150ms ease-out;

    &:hover {
      opacity: 1;
    }
  }
}

            
          
!
            
              new Vue({
  el: '#app',
  data() {
    return {
      modal: false,
      points: { a: -1, b: -1, c: -1, d: -1, e: -1 }
    }
  },
  
  computed: {
    path() {
      return Object.keys(this.points)
        .filter(key => ~'abcde'.indexOf(key))
        .map((key, i) => [i * 100, 100 - this.points[key]])
    }
  },
  
  methods: {
    setPoint(key) {
      let duration = this.random(3, 5)
      let destination = this.random(0, 100)
      this.animatePoint({ key, duration, destination })
    },
    
    animatePoint({ key, duration, destination }) {
      TweenLite.to(this.points, duration, {
				[key]: destination,
				ease: Sine.easeInOut,
				onComplete: this.setPoint,
				onCompleteParams: [key]
			})
    },
    
    random(min, max) {
			return ((Math.random() * (max - min)) + min).toFixed(2)
		}
  },
  
  mounted() {
    Object.keys(this.points).forEach(this.setPoint)
  }
})
            
          
!
999px
Loading ..................

Console