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

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="transition-components-demo" class="demo">
  
  <div class="btn-group-wrap">
    <div class="btn-group">
      <div 
           v-for="navButton in navButtonSet" 
           type="button" @click="currentSelect = navButton.id, currentIndex = navButton.number, sendLog()" 
           :class="['btn', { 'btn-primary': navButton.number === currentIndex, 'btn-default': navButton.number !== currentIndex }]"
           >
             
      </div>
    </div>
    
    <transition name="fade"> 
      <div v-if="slideLeft" class="btn-previous-wrap">
        <div @input="gotToPrev()" @click="gotToPrev()" class="btn-previous"></div>
      </div>
    </transition>
    
    <transition name="fade">
      <div v-if="slideRight" class="btn-next-wrap">
        <div @input="gotToNext()" @click="gotToNext()" class="btn-next"></div>
      </div>
    </transition> 
    
  </div> 

<transition
  v-on:enter="enter"
  v-on:after-enter="afterEnter"					
  v-on:leave="leave"
  v-bind:css="false"
 >
  <component v-bind:is="currentSelect" class="current-slide">
  </component>
</transition>
  
  
</div>
              
            
!

CSS

              
                body
{
    position: fixed;

    overflow: scroll;

    width: 100%;
    height: 100%;
    margin: 0 auto;
    padding: 0 auto;

    background-color: #090e38;
}


.current-slide
{
    position: absolute;

    width: 100vw;
    height: 100vh;
    margin-top: 0;
    padding: 0;

    background-color: #553890;
}

.current-slide p
{
    font-family: Sans-serif;
    font-size: 2em;

    position: absolute;
    top: 50%;
    left: 50%;

    margin: 0 auto;

    transform: translateY(-50%) translateX(-50%);
    text-align: center;

    color: #fff;
}


.btn
{
    display: inline-block;

    width: 25px;
    height: 25px;
    margin-right: 15px;

    transition: all .5s ease;

    border: solid 1px  #2f1b4e;
    border-radius: 50%;
    outline: none !important;
}


.btn:nth-last-child(1)
{
    margin-right: 0;
}

.btn.btn-primary
{
    border: solid 1px red;
    outline: none;
    background-color: rgb(160,92,255);
    background-color: rgba(160,92,255,.4);
}

.btn.btn-primary:hover
{
    color: #fff;
    border: solid 1px red;
    background-color: #4e2d80;
}

.btn.btn-primary:active,
.btn.btn-primary:focus
{
    color: #fff;
    border: solid 1px red;
    background-color: rgb(160,92,255);
    background-color: rgba(160,92,255,.4);
}


.btn.btn-default
{
    opacity: .7;
}


.btn.btn-default:hover
{
    opacity: 1;
    color: #fff;
    border: solid 1px red;
    background-color: #4b3080;
}

.btn.btn-default:active,
.btn.btn-default:focus
{
    color: #fff;
    background-color: #a05cff;
    background-color: rgb(160,92,255);
    background-color: rgba(160,92,255,.7);
}


.btn-group-wrap
{
    position: fixed;
    z-index: 999;
    bottom: 5%;

    width: 100%;
    height: 25px;
}

.btn-group
{
    position: absolute;
    top: 50%;
    left: 50%;

    transform: translateY(-50%) translateX(-50%);
}

/* Active animation */
.active-animation
{
    position: absolute;
    top: 30px;
    left: 50%;

    transform: translate(-50%, 0);
}

.btn-previous-wrap {
    position: fixed;
    opacity: .07;
    top: 40vh;
    left:25px;
    height: 20vh;
    width: 35px;
    transition: opacity .3s ease;
}

.btn-previous-wrap:hover
{
    opacity: 1;
}

.btn-previous
{
    position: absolute;

    width: 0;
    height: 0;

    opacity: 1;
    border-top: 10vh solid transparent;
    border-right: 35px solid black;
    border-bottom: 10vh solid transparent;
  
    transition: border-right .3s ease;
}

.btn-previous:hover
{
    opacity: 1;
    border-right: 35px solid #7343bc;
}

.btn-next-wrap {
    position: fixed;
    opacity: .07;
    top: 40vh;
    right: 25px;
    height: 20vh;
    width: 35px;
    transition: opacity .3s ease;
}

.btn-next-wrap:hover
{
    opacity: 1;
}

.btn-next
{
    position: absolute;
    top: 0;
    right: 0;

    width: 0;
    height: 0;
   
    opacity: 1;
    border-top: 10vh solid transparent;
    border-bottom: 10vh solid transparent;
    border-left: 35px solid black;
    
    transition: border-left .3s ease;
}

.btn-next:hover
{
    opacity: 1;
    border-left: 35px solid #7343bc;
}


/* Could Use GSAP here as well */
/* Vue JS - Transition Classes */
/* fade in or out - Previous and Next Buttons */

.fade-enter
{
    opacity: 0;
}

.fade-enter-active
{
    transition: opacity 4s ease;
}

.fade-enter-to
{
    /* Vue JS Default is opacity: 1; */
}

.fade-leave
{
    /* Vue JS Default is opacity: 1; */
}

.fade-leave-active
{
    transition: opacity 4s ease;
}

.fade-leave-to
{
    opacity: 0;
}

              
            
!

JS

              
                new Vue({
  el: '#transition-components-demo',
  data() {
    return {
      
      navButtonSet: [ 
        { id: 'slide-0', number: 0 },
        { id: 'slide-1',  number: 1 },
        { id: 'slide-2',  number: 2 },
      ],
      currentSelect: 'slide-0',
      currentIndex: 0,
      
    } 
  },
  computed: {
    
    slideLeft() {
        if ( this.currentIndex === 0 ) {
          return false;
        } else {
          return true;
        }

      },
     
    slideRight() {
        if ( this.currentIndex === this.navButtonSet.length - 1 ) {
          return false;
        } else {
          return true;
        }
    },

    
  },
  mounted() {
    
  },
  components: {
    'slide-0': {
      template: '<div><p>Slide 1</p></div>'
    },
    'slide-1': {
      template: '<div><p>Slide 2</p></div>'
    },
    'slide-2': {
      template: '<div><p>Slide 3</p></div>'
    }
  },
  created() {
    // Global Key Press Listener - For Previous and Next Buttons
    // Since these buttons are not part of a form with an Input Field
    // they do not have focus.
    // Using Vue's @keyup or @keyup.native did not work.
    // Vue forums and Laracst talk about a global listener to solve this 
    window.addEventListener('keyup', this.listenForArrowKeys);
  },
  methods: {
    
    gotToPrev() {
      if ( this.currentIndex === 0 ) {
        return
      } else {
        this.currentIndex--;
         console.log(this.currentIndex + ' = currentIndex - got To Prev Slide');
        this.currentSelect = 'slide-' + `${this.currentIndex}`;
      }
    }, // END gotToPrev
    
    gotToNext() {
      if ( this.currentIndex === this.navButtonSet.length - 1 ) {
        return
      } else {
        this.currentIndex++;
        console.log(this.currentIndex + ' = currentIndex - got To Next Slide');
        this.currentSelect = 'slide-' + `${this.currentIndex}`;
      }
    }, // END gotToNext
    
    sendLog() {
     
      console.log(this.currentSelect + ' = this.currentSelect value');
      
    }, //END sendLog
    
    
    listenForArrowKeys (event) {  
        // If left or right arrow was pressed.
        if (event.keyCode == 37) { 
          console.log('left-arrow-pressed');
          // gotToPrevSlide;
          this.gotToPrev();
        } else if (event.keyCode == 39) { 
          console.log('right-arrow-pressed');
          // gotToNextSlide;
          this.gotToNext();
        } else {
          return   
        } 
      
    }, // END listenForArrowKeys
    
    
    enter(el, done) {
			const tl = new TimelineMax({
				onComplete: done
			})
			
			tl.set(el, {
				x: window.innerWidth * 1.5,
				scale: 0.7,
				transformOrigin: '50% 50%'
			})
			
			tl.to(el, 0.5, {
				x: 0,
				ease: Power4.easeOut
			});
			
			tl.to(el, 1, {
				scale: 1,
				ease: Power4.easeOut
			});
		},
		afterEnter() {
			
		},
		leave(el, done) {
			TweenMax.fromTo(el, 1, {
				autoAlpha: 1
			}, {
				autoAlpha: 0,
				ease: Power4.easeOut,
				onComplete: done
			});
		}
    
  }, // END methods
})
              
            
!
999px

Console