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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <div id="app" class="container">
  <div class="item">
    <div class="part image" @click="nextSlide">
      <image-slide>
        <div class="image-slide" :style="slideImage" :key="activeSlide"></div>
      </image-slide>
    </div> 
    <div class="part text">
      <text-slide>
        <div class="inner" :key="activeSlide">
          <div class="brand">
            The Landscape Book
          </div>
          <div class="centered">
            <h1>{{ activeItem.title }}</h1>
            <h3 :style="descriptionColor">{{ activeItem.description }}</h3>
            <h6>{{ activeItem.creditTitle }}</h6>
            <h5>{{ activeItem.credit }}</h5>
            <button :style="buttonColor" @click="nextSlide"><i class="fa fa-play"></i></button>
          </div>
          <div class="paginator" @click="nextSlide">
            {{ activeSlide+1 }} of {{ slides.length }} <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewBox="0 0 28 10">
    <g>
      <g transform="translate(1147 -1004)">
        <use fill="#303030" transform="translate(-1147 1004)" xlink:href="#path0_fill"/>
      </g>
    </g>
    <defs>
      <path id="path0_fill" d="M27.9 4.309l-2.5-4.1c-.1-.2-.4-.3-.6-.1-.2.1-.3.4-.2.6l2 3.4H.5c-.3-.1-.5.1-.5.4 0 .2.2.5.5.5h26.1l-2.1 3.4c-.1.2-.1.5.2.6h.3c.2 0 .3-.1.4-.2l2.5-4.1c.1-.1.1-.3 0-.4z"/>
    </defs>
  </svg>
          </div>
          <div class="social">
            <ul>
              <li><i class="fa fa-heart-o"></i><span :data-like="activeItem.social.like">{{ activeItem.social.like }}</span></li>
              <li><i class="fa fa-eye"></i><span :data-visit="activeItem.social.visit">{{ activeItem.social.visit }}</span></li>
              <li><i class="fa fa-comment-o"></i><span :data-comment="activeItem.social.comment">{{ activeItem.social.comment }}</span></li>
            </ul>
          </div>
        </div>
      </text-slide>
    </div>
  </div>
  <div class="copyright"><a href="https://dribbble.com/shots/3443280-Fold-animation" target="_blank">Inspired by Fold Animation</a></div>
</div>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Rubik:400,500,700");
@import url("https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css");

$color-primary: #303030;
$color-light: #a0a0a0;

body {
  padding: 0;
  margin: 0;
  font-family: "Rubik", sans-serif;
  -webkit-font-smoothing: antialiased;
  color: $color-primary;
  background: #f0f0f0;
}

.container {
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  width: 100vw;
  height: 100vh;
}

.copyright {
  width: 70%;
  font-size: 11px;
  line-height: 20px;
  text-align: right;

  @media only screen and (min-width: 1600px) {
    width: 1500px;
  }

  a {
    color: $color-primary;
    text-decoration: none;
  }
}

.item {
  display: flex;
  width: 70%;
  background: #fff;
  -webkit-box-shadow: 0 20px 60px 0 rgba(0, 0, 0, .27);
  -moz-box-shadow: 0 20px 60px 0 rgba(0, 0, 0, .27);
  box-shadow: 0 20px 60px 0 rgba(0, 0, 0, .27);

  @media only screen and (max-width: 992px) {
    display: block;
  }
  @media only screen and (min-width: 1600px) {
    width: 1500px;
  }
}

.part {
  position: relative;
  -webkit-flex: 1 0 0;
  flex: 1 0 0;
  height: 450px;
  overflow: hidden;

  @media only screen and (max-width: 1199px) {
    height: 400px;
  }
  @media only screen and (min-width: 1600px) {
    height: 700px;
  }

  &.image {
    order: 2;
    cursor: pointer;

    .image-slide {
      position: absolute;
      top: 0;
      left: 0;
      display: block;
      width: 100%;
      height: 100%;
      overflow: hidden;
      background-position: center center;
      background-repeat: no-repeat;
      background-size: cover;
    }

    img {
      position: absolute;
      top: 0;
      left: 0;
      display: block;
      max-width: 101%;
    }
  }

  &.text {
    order: 1;

    .inner {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 100%;

      .brand {
        position: absolute;
        top: 30px;
        left: 50px;
        font-weight: 500;
      }

      .centered {
        max-width: 60%;
        // transform: translateY(-20px);

        h1 {
          font-size: 21px;
          font-weight: 500;
          text-transform: uppercase;
        }

        h3 {
          font-size: 16px;
          font-weight: 400;
        }

        h5 {
          margin: 0;
          font-size: 13px;
          font-weight: 400;
        }

        h6 {
          margin: 0 0 3px 0;
          font-size: 10px;
          font-weight: 400;
          color: $color-light;
        }

        button {
          width: 50px;
          height: 50px;
          margin-top: 10px;
          color: #fff;
          cursor: pointer;
          background-color: $color-light;
          border: 0;
          border-radius: 50%;
          outline: none;
          -webkit-box-shadow: 0 10px 30px 0 rgba(0, 0, 0, .15);
          -moz-box-shadow: 0 10px 30px 0 rgba(0, 0, 0, .15);
          box-shadow: 0 10px 30px 0 rgba(0, 0, 0, .15);
        }
      }

      .paginator {
        position: absolute;
        bottom: 20px;
        left: 50px;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;

        svg {
          display: inline;
          width: 20px;
        }
      }

      .social {
        position: absolute;
        right: 30px;
        bottom: 20px;
        font-size: 12px;
        color: $color-light;

        ul {
          padding: 0;
          margin: 0;
          list-style: none;

          li {
            display: inline-block;
            margin-left: 10px;

            i {
              margin-right: 5px;
            }

            span {
              display: inline-block;
              width: 15px;
            }
          }
        }
      }
    }
  }
}

              
            
!

JS

              
                Vue.component('image-slide', {
  template: `
<transition
  :css="false"
  name="image-slide"
  mode="in-out"
  @enter="enter"
  @leave="leave"
>
  <slot></slot>
</transition>
`,
  data: () => ({
    anim: null
  }),
  methods: {
    enter (el, onComplete) {
      // console.log('Enter')
      onComplete()
      this.anim = anime({
        targets: el,
        translateY: ['100%', 0],
        easing: 'easeOutCubic',
        duration: 600,
        delay: 600
      })
      // this.anim.play
      // this.isImageLoaded (el.getAttribute('src'))
    },

    leave (el, onComplete) {
      anime({
        targets: el,
        translateY: [0, '-100%'],
        easing: 'easeOutSine',
        duration: 600,
        delay: 700,
        complete: onComplete
      })
    },

    isImageLoaded (src) {
      this.isLoaded = false
      var img = new Image()
      img.onload = () => {
        // the image is ready
        this.isLoaded = true
        // console.log('loaded')
        // this.anim.play
      }
      img.onerror = function () {
        // the image has failed
      }
      img.src = src
    }
  }
})

Vue.component('text-slide', {
  template: `
<transition
  :css="false"
  name="text-slide"
  mode="out-in"
  @enter="enter"
  @leave="leave"
>
  <slot></slot>
</transition>
`,
  data: () => ({
    anim: null
  }),
  methods: {
    enter (el, onComplete) {
      console.log('ENTER')
      let timeline = anime.timeline({ complete: onComplete })
      timeline.add({
        targets: [
          '.centered h1',
          '.centered h3',
          '.centered h6',
          '.centered h5',
          '.centered button'
        ],
        translateY: [250, 0],
        easing: 'easeOutSine',
        duration: 500,
        opacity: [0, 1],
        delay: (el, i, l) => i * 100
      })
      timeline.add({
        targets: '.paginator',
        translateX: [-50, 0],
        easing: 'easeOutSine',
        duration: 300,
        opacity: [0, 1],
        offset: 0
      })
      timeline.add({
        targets: '.social',
        translateY: [30, 0],
        easing: 'easeOutSine',
        duration: 300,
        opacity: [0, 1],
        offset: 0
      })
      
      const socialObj = { like: 0, visit: 0, comment: 0 }
      const elLike = document.querySelector('[data-like]')
      const elVisit = document.querySelector('[data-visit]')
      const elComment = document.querySelector('[data-comment]')
      timeline.add({
        targets: socialObj,
        like: elLike.dataset.like,
        visit: elVisit.dataset.visit,
        comment: elComment.dataset.comment,
        round: 1,
        duration: 900,
        easing: 'easeInQuad',
        offset: -50,
        update: function () {
          elLike.innerHTML = socialObj.like
          elVisit.innerHTML = socialObj.visit
          elComment.innerHTML = socialObj.comment
        }
      })
    },

    leave (el, onComplete) {
      console.log('LEAVE')
      
      let timeline = anime.timeline({
        complete: onComplete
      })
      
      timeline.add({
        targets: [
          '.part.text h1',
          '.part.text h3',
          '.centered h6',
          '.centered h5',
          '.centered button'
        ],
        translateY: [0, -250],
        easing: 'easeInExpo',
        duration: 500,
        opacity: [1, 0],
        delay: (el, i, l) => i * 100
      })
      timeline.add({
        targets: '.paginator',
        translateX: [0, 120],
        easing: 'easeInExpo',
        duration: 300,
        opacity: [1, 0],
        offset: 0
      })
      timeline.add({
        targets: '.social',
        translateY: [0, -80],
        easing: 'easeInExpo',
        duration: 300,
        opacity: [1, 0],
        offset: 0
      })
    }
  }
})

new Vue({
  el: '#app',
  data: () => ({
    activeSlide: 0,
    slides: [
      {
        title: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
        description: 'Aliquam sed purus commodo, mattis dui ut',
        creditTitle: 'Photographed by',
        credit: 'Laurus Molden',
        image: 'https://unsplash.it/700?image=10',
        color: '#558B2F',
        social: {
          like: 88,
          visit: 254,
          comment: 7
        }
      },
      {
        title: 'Aliquam sed purus commodo, mattis dui ut, suscipit risus',
        description: 'Proin aliquet ipsum quis arcu',
        creditTitle: 'Photographed by',
        credit: 'John Wizinger',
        image: 'https://unsplash.it/700?image=11',
        color: '#009688',
        social: {
          like: 19,
          visit: 324,
          comment: 11
        }
      },
      {
        title: 'Proin aliquet ipsum quis arcu hendrerit elementum',
        description: 'Lorem ipsum dolor sit amet, consectetur',
        creditTitle: 'Photographed by',
        credit: 'Jacob Bodo',
        image: 'https://unsplash.it/700?image=12',
        color: '#FFC107',
        social: {
          like: 56,
          visit: 119,
          comment: 21
        }
      }
    ]
  }),
  computed: {
    slideImage () {
      console.log(this.activeSlide)
      return {
        backgroundImage: `url("${this.slides[this.activeSlide].image}")`
      }
    },
    activeItem () {
      return this.slides[this.activeSlide]
    },
    buttonColor () {
      return {
        backgroundColor: this.slides[this.activeSlide].color
      }
    },
    descriptionColor () {
      return {
        color: this.slides[this.activeSlide].color
      }
    }
  },
  methods: {
    nextSlide () {
      if (this.activeSlide >= this.slides.length - 1) {
        this.activeSlide = 0
      } else {
        this.activeSlide++
      }
    }
  }
})

              
            
!
999px

Console