
Untitled
By: a guest on
Jun 30th, 2012 | syntax:
None | size: 1.78 KB | hits: 18 | expires: Never
Need help reversing a function; reverting an animated expansion of a div
jQuery().ready(function() {
// Variables - Project Tiles
var $tile = jQuery(".tile");
//Expands tile on click
jQuery($tile).click(function(){
$tile
.stop()
jQuery(this).addClass('expanded'); //change cell's class
jQuery(".tile-content", this).hide(); //hide starting content
jQuery(this).animate({ //animate the expansion of the cell
width: '933px',
height: 'auto',
}, "slow", function() { //things to do after animation
jQuery(".expanded-content", this).fadeIn('slow'); //show post content
jQuery("#content").isotope({ //re-arrange tiles
sortBy : 'width',
});
});
});
// close tile
});
<div id="container">
<div class="tile-holder">
<div class="tile"></div>
</div>
<div class="tile-holder">
<div class="tile"></div>
</div>
...
</div>
jQuery(function(){
var $container = jQuery('#container'),
$tileHolders = jQuery('.tile-holder');
$container.isotope({
itemSelector: '.tile-holder',
masonry: {
columnWidth: 60
},
getSortData : {
width : function( $item ){
// sort by biggest width first, then by original order
return -$item.width() + $item.index();
}
},
sortBy : 'width'
})
$tileHolders.click(function(){
var $this = jQuery(this),
tileStyle = $this.hasClass('big') ? { width: 50, height: 50} :
{ width: 170, height: 110};
$this.toggleClass('big');
$this.find('.tile').stop().animate( tileStyle );
// update sortData for new tile's width
$container.isotope( 'updateSortData', $this ).isotope();
});
});