Skip to content

Commit

Permalink
[closes 17] Added a destroy method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam committed Jan 24, 2015
1 parent d5c1b52 commit 42067a2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -73,6 +73,11 @@ If you would like to keep the grids in sync on document ready, window load and r
$('.group-of-elements').responsiveEqualHeightGrid();
```

To clean up, you can call a destroy method.

```
$('.group-of-elements').responsiveEqualHeightGridDestroy();
```

The MIT License (MIT)

Expand Down
21 changes: 19 additions & 2 deletions grids.js
@@ -1,3 +1,7 @@
/**
* Javascript-Equal-Height-Responsive-Rows
* https://github.com/Sam152/Javascript-Equal-Height-Responsive-Rows
*/
(function($) {
'use strict';

Expand Down Expand Up @@ -61,15 +65,28 @@
/**
* Ensure equal heights now, on ready, load and resize.
*/
var grids_event_uid = 0;
$.fn.responsiveEqualHeightGrid = function() {
var _this = this;

var event_namespace = '.grids_' + grids_event_uid;
_this.data('grids-event-namespace', event_namespace);
function syncHeights() {
var cols = _this.detectGridColumns();
_this.equalHeightGrid(cols);
}
$(window).bind('resize load', syncHeights);
$(window).bind('resize' + event_namespace + ' load' + event_namespace, syncHeights);
syncHeights();
grids_event_uid++;
return this;
};

/**
* Unbind created events for a set of elements.
*/
$.fn.responsiveEqualHeightGridDestroy = function() {
var _this = this;
_this.css('height', 'auto');
$(window).unbind(_this.data('grids-event-namespace'));
return this;
};

Expand Down
6 changes: 5 additions & 1 deletion grids.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 42067a2

Please sign in to comment.