LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

FLIPing Slides With <transition-group>

Notice how this small text and the title above smoothly transition to new positions based on the height of the new content? That's FLIPing awesome.
CSS
.sg-left-move,
.sg-right-move {
  -webkit-transition: -webkit-transform 0.6s cubic-bezier(0.29, 0.15, 0.24, 0.97);
  transition: -webkit-transform 0.6s cubic-bezier(0.29, 0.15, 0.24, 0.97);
  transition: transform 0.6s cubic-bezier(0.29, 0.15, 0.24, 0.97);
  transition: transform 0.6s cubic-bezier(0.29, 0.15, 0.24, 0.97), -webkit-transform 0.6s cubic-bezier(0.29, 0.15, 0.24, 0.97);
}
.sg-left-leave-active,
.sg-right-leave-active {
  -webkit-transition: opacity 0.3s linear, -webkit-transform 0.3s cubic-bezier(0.64, 0.01, 0.67, 0.92);
  transition: opacity 0.3s linear, -webkit-transform 0.3s cubic-bezier(0.64, 0.01, 0.67, 0.92);
  transition: opacity 0.3s linear, transform 0.3s cubic-bezier(0.64, 0.01, 0.67, 0.92);
  transition: opacity 0.3s linear, transform 0.3s cubic-bezier(0.64, 0.01, 0.67, 0.92), -webkit-transform 0.3s cubic-bezier(0.64, 0.01, 0.67, 0.92);
}
.sg-left-enter-active,
.sg-right-enter-active {
  -webkit-transition: opacity 0.3s linear, -webkit-transform 0.3s cubic-bezier(0.29, 0.15, 0.24, 0.97);
  transition: opacity 0.3s linear, -webkit-transform 0.3s cubic-bezier(0.29, 0.15, 0.24, 0.97);
  transition: opacity 0.3s linear, transform 0.3s cubic-bezier(0.29, 0.15, 0.24, 0.97);
  transition: opacity 0.3s linear, transform 0.3s cubic-bezier(0.29, 0.15, 0.24, 0.97), -webkit-transform 0.3s cubic-bezier(0.29, 0.15, 0.24, 0.97);
  -webkit-transition-delay: .25s, .3s;
          transition-delay: .25s, .3s;
}
.sg-left-enter,
.sg-right-enter,
.sg-left-leave-to,
.sg-right-leave-to {
  opacity: 0;
}
.sg-left-leave-to,
.sg-right-enter {
  -webkit-transform: translateX(30%);
          transform: translateX(30%);
}
.sg-left-enter,
.sg-right-leave-to {
  -webkit-transform: translateX(-30%);
          transform: translateX(-30%);
}
/* ////////////////////////////////////////////////////////////////////////// */
.sg-3d-left-move,
.sg-3d-right-move {
  -webkit-transition: -webkit-transform 0.6s cubic-bezier(0.29, 0.15, 0.24, 0.97);
  transition: -webkit-transform 0.6s cubic-bezier(0.29, 0.15, 0.24, 0.97);
  transition: transform 0.6s cubic-bezier(0.29, 0.15, 0.24, 0.97);
  transition: transform 0.6s cubic-bezier(0.29, 0.15, 0.24, 0.97), -webkit-transform 0.6s cubic-bezier(0.29, 0.15, 0.24, 0.97);
}
.sg-3d-left-leave-active,
.sg-3d-right-leave-active,
.sg-3d-left-enter-active,
.sg-3d-right-enter-active {
  -webkit-transform: perspective(700px) rotateY(0deg);
          transform: perspective(700px) rotateY(0deg);
}
.sg-3d-left-leave-active,
.sg-3d-right-leave-active {
  -webkit-transition: opacity 0.1s linear, -webkit-transform 0.3s cubic-bezier(0.64, 0.01, 0.67, 0.92);
  transition: opacity 0.1s linear, -webkit-transform 0.3s cubic-bezier(0.64, 0.01, 0.67, 0.92);
  transition: transform 0.3s cubic-bezier(0.64, 0.01, 0.67, 0.92), opacity 0.1s linear;
  transition: transform 0.3s cubic-bezier(0.64, 0.01, 0.67, 0.92), opacity 0.1s linear, -webkit-transform 0.3s cubic-bezier(0.64, 0.01, 0.67, 0.92);
  -webkit-transition-delay: 0s, .2s;
          transition-delay: 0s, .2s;
}
.sg-3d-left-enter-active,
.sg-3d-right-enter-active {
  -webkit-transition: opacity 0.1s linear, -webkit-transform 0.3s cubic-bezier(0.29, 0.15, 0.24, 0.97);
  transition: opacity 0.1s linear, -webkit-transform 0.3s cubic-bezier(0.29, 0.15, 0.24, 0.97);
  transition: transform 0.3s cubic-bezier(0.29, 0.15, 0.24, 0.97), opacity 0.1s linear;
  transition: transform 0.3s cubic-bezier(0.29, 0.15, 0.24, 0.97), opacity 0.1s linear, -webkit-transform 0.3s cubic-bezier(0.29, 0.15, 0.24, 0.97);
  -webkit-transition-delay: .2s, .2s;
          transition-delay: .2s, .2s;
}
.sg-3d-left-enter,
.sg-3d-right-enter,
.sg-3d-left-leave-to,
.sg-3d-right-leave-to {
  opacity: 0;
}
.sg-3d-left-leave-to,
.sg-3d-right-enter {
  -webkit-transform: perspective(700px) translateZ(-300px) rotateY(90deg);
          transform: perspective(700px) translateZ(-300px) rotateY(90deg);
}
.sg-3d-left-enter,
.sg-3d-right-leave-to {
  -webkit-transform: perspective(700px) translateZ(-300px) rotateY(-90deg);
          transform: perspective(700px) translateZ(-300px) rotateY(-90deg);
}
/* ////////////////////////////////////////////////////////////////////////// */
.slide-group {
  width: 80%;
  max-width: 30em;
  margin: auto;
  text-align: center;
}
.slide {
  background: #FFF;
  text-align: left;
  border: solid 1px #ccc;
  padding: 1rem;
  margin: 1rem 0;
}
.slide img {
  display: block;
  margin-bottom: 1rem;
}
/* ////////////////////////////////////////////////////////////////////////// */
.nav-container {
  width: 90%;
  max-width: 36em;
  margin: auto;
  position: absolute;
  position: fixed;
  top: 50%;
  left: 0;
  right: 0;
  -webkit-transform: translateY(-50%);
          transform: translateY(-50%);
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: justify;
      -ms-flex-pack: justify;
          justify-content: space-between;
  z-index: 2;
}
.nav {
  display: block;
  width: 2em;
  fill: none;
  stroke: #000;
  cursor: pointer;
  -webkit-transition: stroke 0.2s linear;
  transition: stroke 0.2s linear;
}
.nav:hover,
.nav:focus {
  stroke: #f15268;
}
/* ////////////////////////////////////////////////////////////////////////// */
.preloader {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 1px;
  box-sizing: content-box;
  overflow: hidden;
}
/* ////////////////////////////////////////////////////////////////////////// */
* {
  box-sizing: border-box;
}
button {
  cursor: pointer;
}
svg,
img {
  max-width: 100%;
  height: auto;
}
h1,
h2,
h3,
h4,
h5,
p {
  margin: 0 0 1rem;
}
body :last-child {
  margin-bottom: 0;
}
html {
  width: 100%;
  height: 100%;
  background: #eee;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
}
body {
  margin: auto;
  width: 100%;
  position: relative;
}
JS
console.clear();

new Vue({  

  el: '#app',
   
  // Give everyone a little eye candy right off the bat.
  mounted(){
    setTimeout(()=>{ this.nav(1); },200);
  },

  methods: {

    nav(dir){
      this.dir = dir;
      var len = this.slides.length;
      // Loop around the array so last slide goes to first slide & vice-versa.
      this.current = ( ( this.current + dir % len) + len ) % len; 
    },

    // When transitioning an element out, applying `position: absolute` or `position: fixed` keeps the container from snapping in size dramatically and helps the whole transition run smoother. 
    // You can use CSS on the `-leave-active` class (see commented out CSS in the CSS tab), but that often leads to the element flying out in weird directions or snapping to the edges of the container.
    // Instead, let's apply the positioning in JavaScript with `position: fixed` and the right positioning + sizing to elements that are leaving so they don't snap in odd ways.
    sgBeforeLeave(el){
      var rect = el.getBoundingClientRect();
      el.style.width = (rect.right - rect.left) + 'px';
      el.style.height = (rect.bottom - rect.top) + 'px';
      el.style.position = 'fixed'; 
      el.style.top = rect.top + 'px'; 
      el.style.left = rect.left + 'px';
    }
  },

  computed: {
    transitionName(){
      return 'sg-' + 
        ( this.use3d ? '3d-' : '' ) + 
        ( this.dir > 0 ? 'right' : 'left' );
    }
  },

  data: ()=>({
    dir: 0,
    current: 0,
    use3d: true,
    slides: [{
      image: 'https://unsplash.it/800/300/?image=997',
      content: '

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent bibendum, lorem vel tincidunt imperdiet, nibh elit laoreet felis, a bibendum nisl tortor non orci. Donec pretium fermentum felis, quis aliquet est rutrum ut. Integer quis massa ut lacus viverra pharetra in eu lacus.

Aliquam tempus odio adipiscing diam pellentesque rhoncus. Curabitur a bibendum est. Mauris vehicula cursus risus id luctus. Curabitur accumsan venenatis nibh, non egestas ipsum vulputate ac. Vivamus consectetur dolor sit amet enim aliquet eu scelerisque ipsum hendrerit. Donec lobortis suscipit vestibulum. Nullam luctus pellentesque risus in ullamcorper. Nam neque nunc, mattis vitae ornare ut, feugiat a erat. Ut tempus iaculis augue vel pellentesque.

' },{ image: 'https://unsplash.it/800/300/?image=994', content: '

Vestibulum nunc massa, gravida quis porta nec, feugiat id metus. Nunc ac arcu dolor, quis vestibulum leo. Cras viverra mollis ipsum, non rhoncus lectus aliquam et. Morbi faucibus purus sit amet lacus aliquet elementum. Donec sit amet posuere enim. Cras in eros id tortor fringilla ultricies. Mauris faucibus ullamcorper velit, pulvinar varius odio eleifend eu.

', },{ image: 'https://unsplash.it/800/300/?image=993', content: '

Donec nunc ligula, vulputate quis mollis eu, interdum quis libero. Donec nulla ante, facilisis sit amet vulputate at, tincidunt a velit. Maecenas vestibulum, nulla sed tincidunt viverra, lorem turpis aliquam urna, ut pretium orci purus consequat augue. Etiam a enim orci, vitae pulvinar odio.

In elit urna, tincidunt a pellentesque et, scelerisque at nibh. Sed nec est sapien. Aliquam ullamcorper eros eu quam ultrices vel faucibus eros interdum. Etiam mattis eleifend sapien, eu iaculis massa feugiat sed. Aliquam erat volutpat. Vivamus facilisis ultricies eros, a pretium purus mollis id. Sed dapibus elit ut neque rutrum dignissim.Nulla eros nisl, venenatis quis rhoncus sit amet, molestie nec nisl. Pellentesque vel neque sapien, et sagittis nulla. Quisque id odio metus. Morbi adipiscing ultricies posuere. Pellentesque elementum porttitor eros in molestie. Maecenas ut leo quis nisi tempor tincidunt.

', },{ image: 'https://unsplash.it/800/300/?image=991', content: '

Aliquam eu iaculis mauris. Etiam arcu lectus, imperdiet sit amet volutpat vitae, commodo sed nibh. Fusce faucibus tempor cursus. Donec ut ligula tortor. Maecenas malesuada, diam vitae pharetra dictum, erat ante iaculis risus, sed sollicitudin nisl nisl vel metus. Nulla libero augue, convallis nec luctus id, iaculis nec urna. Cras vitae mi ut augue ultricies tempus.

', },{ image: 'https://unsplash.it/800/300/?image=990', content: '

Vestibulum euismod vehicula sollicitudin. Duis nibh justo, rhoncus ac ullamcorper nec, rutrum sit amet leo. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum varius posuere nisi sed aliquet. Etiam dolor nisi, placerat vel congue tempus, posuere sed erat.

Phasellus turpis eros, molestie sed consequat in, pretium at erat. In sed faucibus metus. Vestibulum fermentum libero nec eros fermentum dapibus. Duis nec libero eros. Pellentesque magna ligula, sagittis dictum fringilla at, posuere porttitor sem. Donec aliquam, ipsum quis pulvinar dapibus, augue sem viverra sapien, nec tempus odio nulla ac metus. Nunc ut augue mi, nec consequat urna.

', },{ image: 'https://unsplash.it/800/300/?image=994', content: '

Maecenas vestibulum, nulla sed tincidunt viverra, lorem turpis aliquam urna, ut pretium orci purus consequat augue. Etiam a enim orci, vitae pulvinar odio.

' } ] }), });
Host Instantly Drag and Drop Website Builder

 

Description

Vue's <transition-group> contains built in FLIP animation features, and allows for some really powerful CSS transitions.
Term
Mon, 11/27/2017 - 22:05

Related Codes

Pen ID
Pen ID
Pen ID