cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

              <!-- Adding TweenMax (or TweenLite+CSSPLugin) and Draggable -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gsap/latest/utils/Draggable.min.js"></script>

<!-- The actual markup -->
<ul id="controls">
	<li class="to-start">Before</li>
	<li class="to-middle">Compare</li>
	<li class="to-end">After</li>
<div id="before-after">
	<div class="view view-after"><img src="http://cloud.bassta.bg/img-after.jpg" /></div>
	<div class="view view-before"><img src="http://cloud.bassta.bg/img-before.jpg" /></div>
	<div id="dragme"></div>
              body, div, p{
	margin: 0;
	padding: 0;
	font-family: Helvetica, sans-serif;
		position: relative;
		width: 600px;
		height: 500px;
		border: 2px solid grey;
		margin: 50px auto 0px;;
			position: absolute;
			top: 0px;
			left: 0px;
			width: 100%;
			height: 100%;
			overflow: hidden;
			  z-index: 100;
				z-index: 200;
				position: absolute;
				width: 5px;
				height: 100%;
				top: 0px;
				left: 0px;
				background-color: black;
				cursor: pointer;
				z-index: 300;
			text-align: center;
			margin-top: 50px;
			ul li{
				list-style: none;
				display: inline-block;
				font-size: 17px;
				cursor: pointer;
				margin: 0px 20px 0px 20px
    Dependencies : TweenMax and Draggable
    Images by Ivaylo Yovchev ( http://www.ivayloyovchev.com/ )
    Test on touch device @ http://cloud.bassta.bg/before-after.html
  var $dragMe			    = $("#dragme");
  var $beforeAfter		= $("#before-after");
  var $viewAfter		  = $(".view-after");
  Draggable.create($dragMe, {
	  bounds: $beforeAfter,
  function updateImages(){
	  TweenLite.set($viewAfter, {width: $dragMe.css("left") });		//or this.x if only dragging
  //Intro Animation
  //Externall nav
  $(".to-start").on("click", function(){
  $(".to-middle").on("click", function(){
  $(".to-end").on("click", function(){
  function animateTo(_left){
	  TweenLite.to( $dragMe, 1, {left: _left, onUpdate: updateImages });
  //V2 Click added
  $beforeAfter.on("click", function(event){			   		
	  var eventLeft = event.clientX - $beforeAfter.offset().left;
});//end jQuery wrapper
Loading ..................