Skip to content

Instantly share code, notes, and snippets.

@chrsr
Last active December 22, 2015 06:29
Show Gist options
  • Save chrsr/6431662 to your computer and use it in GitHub Desktop.
Save chrsr/6431662 to your computer and use it in GitHub Desktop.
A Pen by Chris Roberts.
<button>Narrow down</button>
<div class="container">
<div class="box box-1">1</div>
<div class="box box-2">2</div>
<div class="box box-3">3</div>
<div class="box box-4">4</div>
<div class="box">5</div>
<div class="box">6</div>
<div class="box">7</div>
<div class="box">8</div>
<div class="box">9</div>
</div>
$('button').on('click', function () {
// how many are getting removed ?
// calculate width
var box1 = $('.box:nth-child(1)');
var box2 = $('.box:nth-child(2)');
box2.addClass('prep-animate');
box2.addClass('animate');
box1.fadeOut(function() {
box2.removeClass('prep-animate');
box2.removeClass('animate');
$(this).remove();
});
});
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
button {
margin: 0 0 10px;
}
.container {
overflow: hidden;
width: 630px;
}
.box {
display: flex;
float: left;
width: 200px;
height: 200px;
margin: 0 10px 10px 0;
background: #444;
justify-content: center;
align-items: center;
color: #fff;
font-size: 40px;
font-family: sans-serif;
}
.clone {
background: none;
}
.prep-animate {
transition: all 0.4s ease-out;
}
.animate {
margin-left: -210px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment