Skip to content
This repository has been archived by the owner on Feb 6, 2019. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Recount columns on browser window resize
  • Loading branch information
chadoh committed Feb 10, 2013
1 parent b31d082 commit 39bc181
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions themes/immerse/public/immerse/javascripts/application.js
Expand Up @@ -46,4 +46,23 @@ $(function(){
setColCountProp();
adjustHeight();
}

/* fire a `resizeEnd` function when window resizing pauses for >=500ms
* from http://stackoverflow.com/a/2996465/249801 */
$(window).resize(function() {
if(this.resizeTo) clearTimeout(this.resizeTo);
this.resizeTo = setTimeout(function() {
$(this).trigger('resizeEnd');
}, 500);
});

$(window).on('resizeEnd', function(){
/* reset to how it was at page load... */
cols.css(colCountProp, '2');
cols.css( 'width', cols.parent().css('width') );

/* and readjust the height! */
adjustHeight();
});

});

0 comments on commit 39bc181

Please sign in to comment.