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 class="wrapper">
  <div class="revealImage withImage"></div>
  <div class="revealImage withOutImage"></div>
  
<!--   <div class="dragger"> -->
    <div class="dragger">
      <div class="outerShadow"></div><span>Drag for More</span><div class="innerShadow"></div>
      <div class="icon"></div>
    </div>
<!--   </div> -->
  
</div>
              
            
!

CSS

              
                .wrapper{
  height:100vh;
  width:100vw;
  background:linear-gradient(#eee, #aaa);
}
.withImage{
  width:100%;
  height:100%;
  top:0;
  left:0;
  position:absolute;
  background-image:url(https://images.unsplash.com/photo-1469173479606-ada03df615ac?dpr=1&auto=format&fit=crop&w=1500&h=1000&q=80&cs=tinysrgb&crop=);
  background-repeat:no-repeat;
  background-position:0 center;
}
.withOutImage{
  width:50%;
  height:100%;
  top:0;
  left:0;
  position:absolute;
  filter:brightness(60%) grayscale(100%);
  background-image:url(https://images.unsplash.com/photo-1469173479606-ada03df615ac?dpr=1&auto=format&fit=crop&w=1500&h=1000&q=80&cs=tinysrgb&crop=);
  background-repeat:no-repeat;
  background-position:0 center;
  border-right:1px solid rgba(white, .5)
}

.dragger{
  position:absolute;
  // top:0;
  left:calc(50% - 25px);
  width:1px;
  height:100%;
  background:rgba(white,.55);
  cursor:ew-resize!important;
  width:50px;
  height:50px;
  border-radius:100%;
  bottom:20%;
  
  .icon{
    position:absolute;
    top:0;
    left:0;
    z-index:10;
    width:50px;
    height:50px;
    border-radius:100%;
    border:2px solid orange;
    background:#111;
  }
  .innerShadow{
    border-radius: 1000px;
    width:78px;
    height: 78px;
    position: absolute;
    top:-12px;
    left:-12px;
    z-index: 5;
    box-shadow:0 0 25px rgba(black, .88);
  }
  .outerShadow{
    border-radius: 1000px;
    width:115px;
    height: 115px;
    position: absolute;
    z-index: 1;
    top:-30px;
    left:-30px;
    box-shadow:0 0 25px rgba(black, .69);
  }

  span{
    font-size: 10px;
    font-style: italic;
    background:orange;
    line-height: 22px;
    height: 22px;
    padding:0 22px 0 22px;
    border-radius: 55px;
    color:white;
    z-index: 2;
    position: absolute;
    display: inline-block;
    right: 30px;
    top:16px;
    width:80px;

  }
}
              
            
!

JS

              
                var imgWidth;
var imgHeight;
var bgWidth;
var bgHeight;
var actualImage = new Image();
var sizeRatio;
var widthVal;
var setWidth;
var fitWidth;
actualImage.src = $('.revealImage').css('background-image').replace(/"/g,"").replace(/url\(|\)$/ig, "");
actualImage.onload = function(){
  imgWidth = this.width;
  imgHeight = this.height;

  function getWidth() {
    console.log(imgWidth);
    bgWidth = $('.wrapper').outerWidth();
    bgHeight = $('.wrapper').outerHeight();

    sizeRatio = (((imgWidth * bgHeight) / bgWidth) / imgHeight);
    widthVal = sizeRatio * bgWidth + 5;
    setWidth = widthVal + 'px';
    fitWidth = bgWidth + 'px';
    var resizeOffset = $('.dragger').offset(),
        resizeXOffset = (resizeOffset.left + 25) / bgWidth * 100 ;
    console.log(sizeRatio);
    if(sizeRatio > 1){
      $('.revealImage').css({backgroundSize: setWidth });
    }else{
      $('.revealImage').css({backgroundSize: fitWidth });
    }
    // TweenMax.set('.dragger', {transformOrigin:'50% 50%'})
    TweenLite.set('.withOutImage', { width:resizeXOffset + '%'});

  };
  getWidth();
  $(window).resize(function(){
    getWidth();
    // console.log(fitWidth);
  });

  return getWidth;

}
Draggable.create('.dragger', {
  type: 'x',
  throwProps: true,
  bounds: $('.wrapper'),
  resistance: 300,
  zIndexBoost: false,
  onDrag: function() {
    var xOffset = (this.x + bgWidth / 2) / bgWidth * 100;
    TweenLite.set('.withOutImage', {width: xOffset + '%'})
  },
  onThrowUpdate: function() {
    var xOffset = (this.x + bgWidth/2)/bgWidth*100;
    // console.log(xOffset)
    TweenLite.set('.withOutImage', {width:xOffset + '%'})
  }
})
              
            
!
999px

Console