123

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.

            
              header
  h1 Clockwerk
  small 
    | Photography &copy;
    a(href="http://alexdemora.com/") Alex de Mora
nav
  a(href="#").btn.prev &larr;
  a(href="#").btn.next &rarr;

section
  .layer.image-1
    .slice.left
      .inner
    .slice.right
      .inner

  .layer.image-2
    .slice.left
      .inner
    .slice.right
      .inner

  .layer.image-3
    .slice.left
      .inner
    .slice.right
      .inner

  .layer.image-4
    .slice.left
      .inner
    .slice.right
      .inner

            
          
!
            
              $img-1: url( "http://assets.droom.io/codepen/01.jpg" )
$img-2: url( "http://assets.droom.io/codepen/02.jpg" ) 
$img-3: url( "http://assets.droom.io/codepen/03.jpg" ) 
$img-4: url( "http://assets.droom.io/codepen/04.jpg" ) 

@mixin spin
  transition: all 400ms linear

@mixin spin-in
  transition: all 400ms ease-in

@mixin spin-out
  transition: all 400ms ease-out

@keyframes btn-wake
  0%
    opacity: 1
  50%
    opacity: 0
  100%
    opacity: 1

body
  margin:           0
  padding:          0
  background-color: pink
  font-family:      helvetica, arial, sans-serif
  display:          flex
  align-items:      center
  justify-content:  center
  height:           100vh
  width:            100vw

header
  color:      white
  position:   fixed
  width:      100%
  bottom:     5vh
  text-align: center
  z-index:    98
  
  h1
    font-family:  'Abril Fatface', georgia, times, serif
    font-size:    4rem
    line-height:  4rem
    margin:       0
    padding:      0
    
  small
    font-size:   0.6rem
    line-height: 0.6rem
    margin:      0.6rem 0
    letter-spacing: 0.05em
    display:     block

  a
    color: white
    text-decoration: none

nav
  display: flex
  justify-content: center
  align-items: center
  z-index:  99
  position: fixed
  top:      0
  left:     0
  height: 100vh
  width:  100vw
  
  a
    font-family:  arial
    color:        white
    border:       2px solid white
    padding:      10px 15px
    transition:   100ms ease all
    text-decoration: none
    
    &.wake
      animation-fill-mode: forwards
      animation-iteration-count: 2
      animation-timing-function: ease
      animation-duration: 0.5s
      animation-name: btn-wake
      animation-delay: 1s
  
    &.disable
      opacity: 0.3
      &:hover
        background: none
      &:active
        background: none

    &:hover
      background: rgba(255,255,255,.2)
    &:active
      background: rgba(255,255,255,.7)
    & + a
      margin-left: 60vw

section
  width:      500px
  height:     500px
  min-width:  500px
  margin:     0 auto
  border-radius: 50%
  overflow:   hidden
  position:   relative
  z-index:    1

  .layer
    display: flex
    position: absolute
    top:  0
    left: 0
    width: 100%
    height: 100%

    &:nth-child(1)
      z-index: 4
    &:nth-child(2)
      z-index: 3
    &:nth-child(3)
      z-index: 2
    &:nth-child(4)
      z-index: 1

    &.image-1 .slice
      &.left,
      &.right
        .inner
          background-image: $img-1
          background-color: #6fb4c4
    &.image-2 .slice
      &.left,
      &.right
        .inner
          background-image: $img-2
          background-color: #d25223
    &.image-3 .slice
      &.left,
      &.right
        .inner
          background-image: $img-3
          background-color: #fec763
    &.image-4 .slice
      &.left,
      &.right
        .inner
          background-image: $img-4
          background-color: #a52a2c
    .slice
      width:    50%
      height:   100%
      overflow: hidden

      &.left,
      &.right
        .inner
          width:  100%
          height: 100%

        &.next
          transform: rotate(180deg)
          .inner
            transform: rotate(-180deg)

        &.prev
          transform: rotate(-180deg)
          .inner
            transform: rotate(180deg)

      &.left,
      &.left .inner
        transform-origin: 100% 50%
        background-position: 0 50%

      &.right,
      &.right .inner
        transform-origin: 0 50%
        background-position: 100% 50%

      &.spin-in
        @include spin-in
        .inner
          @include spin-in

      &.spin-out
        @include spin-out
        .inner
          @include spin-out


            
          
!
            
              var blnReady	   = true;
var strPath 	   = 'section .layer';
var strFinished  = 'webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend';

$('.btn').click(function(e) {
  e.preventDefault();

  var top 		= $(strPath).first();
  var bottom 	= $(strPath).last();
  var sliceL	= $(top).find('.slice.left');
  var sliceR	= $(top).find('.slice.right');
  var btn     = $(this);

  if($(btn).hasClass("next") && (blnReady === true)){
    blnReady = false;
    $(btn).addClass('disable');
    $(sliceR).addClass('next spin-in');
    $(sliceR).one(strFinished,   
      function() {
        $(sliceL).addClass('next spin-out');
        $(sliceL).one(strFinished,   
          function() {
            $(top).insertAfter(bottom);
            $(sliceL).removeClass('next spin-out');
            $(sliceR).removeClass('next spin-in');
            $(btn).removeClass('disable');
            blnReady = true;
            return;
          });	
      });
  }

  if($(this).hasClass("prev") && (blnReady === true)){
    blnReady = false;
    $(btn).addClass('disable');
    $(bottom).insertAfter(top);
    $(sliceL).addClass('prev spin-in');
    $(sliceL).one(strFinished,
      function() {
        $(sliceR).addClass('prev spin-out');
        $(sliceR).one(strFinished,   
          function() {
            $(bottom).insertBefore(top);
            $(sliceL).removeClass('prev spin-in');
            $(sliceR).removeClass('prev spin-out');
            $(btn).removeClass('disable');
            blnReady = true;
            return;
          });	
      });
  }
});


$('.btn').hover(function(e) {
  $('.btn').removeClass('wake');
});
$('.btn').addClass('wake');


            
          
!
999px
🕑 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.

Console