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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <body>
<div class="container">
	<section class="clear">
		<header class="list-header">
			<div class="circles">
				<div></div>
				<div></div>
				<div></div>
			</div>		
			<h1>Things To Do</h1>
			<div class="menu">
				<div></div>
				<div></div>
				<div></div>
			</div>
		</header>
			
		<ul class="task-list">
			<li class="task">
				Click and drag this item right to mark it as complete
			</li>
			<li class="task">
				Drag left to delete an item
			</li>
			<li class="task">
				This is the jQuery version - 
			</li>
			<li class="task">
- next up should be pure Javascript!
			</li>	
		</ul>
	</section>
</div>

</body>
<script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
              
            
!

CSS

              
                html{box-sizing:border-box;font-size:62.5%}*,:after,:before{box-sizing:inherit}body{font-size:1.5rem;font-weight:300;line-height:1.6;font-family:'Open Sans',sans-serif}h1{font-size:2rem}a{color:inherit}.container{width:90%;max-width:500px;margin:100px auto}.clear{margin:30px 0}.list-header{display:flex;align-items:center;background-color:#333;border-top-left-radius:5px;border-top-right-radius:5px;padding:10px 20px;color:#fff}.list-header div{width:20%}.list-header .circles div{height:15px;width:15px;border-radius:50%;display:inline-block;margin-right:5px}.list-header .circles div:nth-child(1){background-color:#cff09e}.list-header .circles div:nth-child(2){background-color:#a8dba8}.list-header .circles div:nth-child(3){background-color:#79bd9a}.list-header .menu{display:flex;align-items:flex-end;flex-direction:column}.list-header .menu div{width:25px;height:3px;background-color:#a9a9a9;border-radius:3px}.list-header .menu div:nth-child(2){margin:4px 0}.list-header h1{width:60%;text-align:center}.task-list{background-color:#f2e9e1;min-height:400px;overflow:hidden}.task{width:100%;min-height:50px;line-height:2;position:relative;padding:8px 20px;height:auto;transition:background-color 1s;color:#000}.task:not(.completed):not(.completing):hover{transform:scale(1.1);transform-origin:center left}.task:after,.task:before{position:absolute;top:0;width:40px;height:50px;line-height:50px;text-align:center}.task:before{content:"\2714";left:-40px}.task:after{content:"\2718";right:-40px}.task:nth-child(1){background-color:#e94e77}.task:nth-child(2){background-color:#d68189}.task:nth-child(3){background-color:#c6a49a}.task:nth-child(4){background-color:#c6e5d9}.task.completing{text-decoration:line-through;background-color:#a5d296}.task.completed,.task.deleting{background-color:#323232}.task.completed{opacity:.5;text-decoration:line-through;color:#fff}.task.completed:before{content:""}
              
            
!

JS

              
                $(document).ready(function(){
var clicked = false;
var click_x = 0;
// var container_L = $('.container').offset().left;
// var container_R = $('.container').offset().left + $('.container').width();
// var middle = (container_L + container_R)/2;
var displacement = 0;
var clicked_div = [];

$(document).mouseup(function(e){
    clicked = false;
});

	$('.task-list li').each(function(){

		$(this).on('mousedown', function(e){
			clicked = true;
			click_x = e.pageX;
		});

		$(this).stop().on('mousemove', function(e){
			displacement = e.pageX - click_x ;
			if (clicked ){
				//delete
				if ( displacement < -50  ) {
					$(this).removeClass("completing completed");
					$(this).addClass("deleting");
					$(this).stop().animate({
					//-------------------------------- push left
						left: - $(this).width() - 80
					}, {
					    duration: 500,
					    complete: function () {
					    	//delete from DOM
					    	$(this).remove();
					        //-------------------------------- move the remaining items up the height of the deleted item
					        $(this).nextAll().css("top", -$(this).height()- 20 +"px")
					    }
					});				

				}

				//complete
				else if ( displacement > 50 && !$(this).hasClass("completed") )  {
					$(this).removeClass("deleting completed")
					$(this).addClass("completing");	
					$(this).stop().animate({
						left: $(this).width() + 80,
					}, {
					    duration: 500,
					    complete: function () {
							$(this).removeClass("deleting completing")
							$(this).addClass("completed");	
					    }
					})
					//---------------- when completed, move to the end of the task-list 
					.promise().done(function(){
						$(this).stop().animate({
							left: 0,
						}, {
						    duration: 50,
						    complete: function () {

						    	$('.task-list').append($(this));

						    }
						});
					});			  		
				}
				else {
					//unsure about action - so move +/- from where it is
					$(this).css("left", displacement)
				};

			};

		});
	});
	

});
              
            
!
999px

Console