Permalink
Browse files

Recount columns on browser window resize

  • Loading branch information...
1 parent b31d082 commit 39bc18136dad89ba3913c15d5b6bcabf1a688f74 @chadoh committed Feb 10, 2013
Showing with 19 additions and 0 deletions.
  1. +19 −0 themes/immerse/public/immerse/javascripts/application.js
@@ -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.