Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Recount columns on browser window resize

  • Loading branch information...
commit 39bc18136dad89ba3913c15d5b6bcabf1a688f74 1 parent b31d082
Chad Ostrowski authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 themes/immerse/public/immerse/javascripts/application.js
19 themes/immerse/public/immerse/javascripts/application.js
View
@@ -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();
+ });
+
});
Please sign in to comment.
Something went wrong with that request. Please try again.