You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -28,18 +28,20 @@ See the [jquery.matchHeight.js demo](http://brm.io/jquery-match-height-demo).
28
28
- maintain scroll position
29
29
- data attributes API
30
30
- callback events
31
-
- tested in IE8+, Chrome, Firefox, Chrome Android
31
+
- unit tests
32
+
- module loader support
33
+
- tested in IE8+, Chrome, Firefox, Safari, Android, iOS
32
34
33
35
### Status
34
36
35
-
Current version is `v0.6.0`. <br>
36
-
Use the master build for the latest features. <br>
37
+
Current version is `0.6.0`.
38
+
Use the master build for the latest features.
37
39
Please report any [issues](https://github.com/liabru/jquery-match-height/issues) you find.
38
40
39
41
### Install
40
42
41
43
[jQuery](http://jquery.com/download/) is required, so include it first.
42
-
<br>Download [jquery.matchHeight.js](https://github.com/liabru/jquery-match-height/blob/master/jquery.matchHeight.js) and include the script in your HTML file:
44
+
Download [jquery.matchHeight.js](https://github.com/liabru/jquery-match-height/blob/master/jquery.matchHeight.js) and include the script in your HTML file:
@@ -50,26 +52,31 @@ You can also install using the package managers [Bower](http://bower.io/search/?
50
52
51
53
### Usage
52
54
53
-
$(elements).matchHeight(options);
55
+
$(function() {
56
+
$('.item').matchHeight(options);
57
+
});
54
58
55
-
Where options is an optional parameter. <br>
59
+
Where `options` is an optional parameter.
56
60
See below for a description of the available options and defaults.
57
61
58
-
Call this on the [DOM ready](http://api.jquery.com/ready/) event (the plugin will automatically update on window load). <br>
59
-
See below for examples or the included [test.html](https://github.com/liabru/jquery-match-height/blob/master/test.html).
62
+
The above example will set all selected elements with the class `item` to the height of the tallest.
63
+
If the items are on multiple rows, the items of each row will be set to the tallest of that row (see `byRow` option).
64
+
65
+
Call this on the [DOM ready](http://api.jquery.com/ready/) event (the plugin will automatically update on window load).
66
+
See the included [test.html](https://github.com/liabru/jquery-match-height/blob/master/test/page/test.html) for many working examples.
60
67
61
68
Also see the [Data API](#data-api) below for a simple, alternative inline usage.
62
69
63
70
### Options
64
71
65
-
The default options are:
72
+
The default `options` are:
66
73
67
-
$(elements).matchHeight({
74
+
{
68
75
byRow: true,
69
76
property: 'height',
70
77
target: null,
71
78
remove: false
72
-
});
79
+
}
73
80
74
81
Where:
75
82
@@ -78,51 +85,60 @@ Where:
78
85
-`target` is an optional element to use instead of the element with maximum height
79
86
-`remove` is `true` or `false` to remove previous bindings instead of applying new ones
80
87
81
-
### Examples
82
-
83
-
$(function() {
84
-
$('.item').matchHeight();
85
-
});
86
-
87
-
The above will set all elements with the class `item` to the height of the tallest.<br>
88
-
If the items are on multiple rows, the items of each row will be set to the tallest of that row (see `byRow`).
89
-
90
-
$(function() {
91
-
$('.item').matchHeight({
92
-
target: $('.sidebar')
93
-
});
94
-
});
88
+
### Data API
95
89
96
-
The above will set all elements with the class `item`to the height of the first item with class `sidebar`.
90
+
Use the data attribute `data-mh="group-name"` where `group-name` is an arbitrary string to identify which elements should be considered as a group.
97
91
98
92
<div data-mh="my-group">My text</div>
99
93
<div data-mh="my-group">Some other text</div>
100
94
<div data-mh="my-other-group">Even more text</div>
101
95
<div data-mh="my-other-group">The last bit of text</div>
102
96
103
-
The above will set both elements in `my-group` to the same height as each other.
104
-
It will set both elements in `my-other-group` to be the same height as each other.
105
-
106
-
See the included [test.html](https://github.com/liabru/jquery-match-height/blob/master/test.html) for a working example.
107
-
108
-
### Data API
109
-
110
-
Use the data attribute `data-mh="group-name"` where `group-name` is an arbitrary string to identify which elements should be considered as a group.
111
-
112
97
All elements with the same group name will be set to the same height when the page is loaded, regardless of their position in the DOM, without any extra code required.
113
98
114
99
Note that `byRow` will be enabled when using the data API, if you don't want this (or require other options) then use the alternative method above.
115
100
116
101
### Advanced Usage
117
102
118
-
There are a few internal properties and functions you should know about:
103
+
There are some additional functions and properties you should know about:
119
104
120
105
#### Manually trigger an update
121
106
122
107
$.fn.matchHeight._update()
123
108
124
109
If you need to manually trigger an update of all currently set groups, for example if you've modified some content.
125
110
111
+
#### Row detection
112
+
113
+
You can toggle row detection by setting the `byRow` option, which defaults to `true`.
114
+
It's also possible to use the row detection function at any time:
115
+
116
+
$.fn.matchHeight._rows($('.item'));
117
+
118
+
Which will return an array of element selections for each row, see [this thread](https://github.com/liabru/jquery-match-height/issues/90) for more information and an example.
119
+
120
+
#### Remove bindings
121
+
122
+
$('.item').matchHeight({ remove: true });
123
+
124
+
This will remove all bindings for the selected elements, from all groups.
125
+
126
+
#### Custom target element
127
+
128
+
$(function() {
129
+
$('.item').matchHeight({
130
+
target: $('.sidebar')
131
+
});
132
+
});
133
+
134
+
Will set all selected elements to the height of the first item with class `sidebar`.
This will set the `min-height` property instead of the `height` property.
141
+
126
142
#### Callback events
127
143
128
144
Since matchHeight automatically handles updating the layout after certain window events, you can supply functions as global callbacks if you need to be notified:
@@ -198,6 +214,8 @@ If this is a problem, you should call `_update` once your font has loaded by usi
198
214
199
215
If you change the content inside an element that has had `matchHeight` applied, then you must manually call `$.fn.matchHeight._update()` afterwards. This will update of all currently set equal heights groups.
200
216
217
+
Also note that previous matchHeight bindings do not apply to new elements, even if they match the selector used. In this case you must remove the old bindings and add new ones, see [this comment](https://github.com/liabru/jquery-match-height/issues/60#issuecomment-155913995).
218
+
201
219
### Changelog
202
220
203
221
To see what's new or changed in the latest version, see the [changelog](https://github.com/liabru/jquery-match-height/blob/master/CHANGELOG.md)
0 commit comments