Skip to content

Commit

Permalink
added callback function
Browse files Browse the repository at this point in the history
  • Loading branch information
Saeid Mohadjer authored and Saeid Mohadjer committed Apr 7, 2016
1 parent 47e5677 commit 48bd04c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ $('.parent-element').sameHeight({

//this option by default is false. If set to true css height will be
//used instead of min-height to change height of elements.
useCSSHeight: true
useCSSHeight: true,

//this function will be called every time height is adjusted
callback: function() {
//do something here...
}
});
```

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery.sameHeight",
"version": "0.0.7",
"version": "0.0.8",
"homepage": "https://github.com/smohadjer/sameHeight",
"authors": [
"Saeid Mohadjer <[email protected]>"
Expand Down
18 changes: 11 additions & 7 deletions jquery.sameHeight.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @link https://github.com/smohadjer/jquery.sameHeight
* @license http://opensource.org/licenses/MIT
*
* @version 0.0.7
* @version 0.0.8
*
* based on: http://jqueryboilerplate.com/
* jQuery plugin for making adjacent elements the same height. By default elements
Expand Down Expand Up @@ -55,21 +55,25 @@
$(window).on('resize.' + pluginName, function() {
//remove previously set height or min-height
self.$elms.css(self.cssProperty, '');

//if there are adjacent elements
if (self.getRow(0).length > 1) {
self.setMinHeight(0);
}
initSameHeight();
});

//use setTimeout to make sure any code in stack is executed before
//calculating height
setTimeout(function() {
initSameHeight();
}, 0);

function initSameHeight() {
//if there are adjacent elements
if (self.getRow(0).length > 1) {
self.setMinHeight(0);

if (self.options.callback) {
self.options.callback();
}
}
}, 0);
}
},

setMinHeight: function(index){
Expand Down
2 changes: 1 addition & 1 deletion jquery.sameHeight.min.js

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

0 comments on commit 48bd04c

Please sign in to comment.