20
20
* @param {string } minSize Minimum size for the utility to be activated, empty for small,
21
21
* md for medium, lg for large, xlg for xlarge, max for maximum
22
22
*/
23
- function sameheight ( elemCollection , minSize ) {
23
+ function sameHeight ( elemCollection , minSize = false ) {
24
24
const elemArr = Array . prototype . slice . call ( elemCollection ) ;
25
25
let targetWidth = 0 ;
26
26
if ( minSize ) {
@@ -41,19 +41,26 @@ function sameheight(elemCollection, minSize) {
41
41
}
42
42
43
43
if ( window . innerWidth > targetWidth ) {
44
+ elemArr . forEach ( elem => {
45
+ elem . style . height = 'auto' ;
46
+ } ) ;
44
47
let targetHeight = 0 ;
48
+
45
49
elemArr . forEach ( elem => {
46
50
elem . offsetHeight > targetHeight
47
51
? ( targetHeight = elem . offsetHeight )
48
52
: false ;
49
53
} ) ;
50
54
51
55
elemArr . forEach ( elem => {
52
- elem . offsetHeight == targetHeight
53
- ? ( elem . style . height = 'auto' )
54
- : ( elem . style . height = targetHeight + 'px' ) ;
56
+ elem . offsetHeight == targetHeight ;
57
+ elem . style . height = targetHeight + 'px' ;
58
+ } ) ;
59
+ } else {
60
+ elemArr . forEach ( elem => {
61
+ elem . style . height = 'auto' ;
55
62
} ) ;
56
63
}
57
64
}
58
65
59
- export default sameheight ;
66
+ export default sameHeight ;
0 commit comments