dotsunited-equal-height-blocks
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -1,47 +0,57 @@ | ||
var $ = require('jquery'); | ||
(function(window, factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
define(['jquery'], function($) { | ||
return factory(window, $); | ||
}); | ||
} else if (typeof module === 'object' && typeof module.exports === 'object') { | ||
module.exports = factory(window, require('jquery')); | ||
} else { | ||
window.dotsunitedEqualHeightBlocks = factory(window, window.jQuery || window.Zepto); | ||
} | ||
}(typeof window !== 'undefined' ? window : this, function(window, $) { | ||
return function(containerSelector, itemSelector) { | ||
function reload() { | ||
var list = $(this), items = list.find(itemSelector); | ||
module.exports = function(containerSelector, itemSelector) { | ||
function reload() { | ||
var list = $(this), items = list.find(itemSelector); | ||
items.css('height', 'auto'); | ||
items.css('height', 'auto'); | ||
var perRow = Math.floor(list.width() / items.width()); | ||
var perRow = Math.floor(list.width() / items.width()); | ||
if (perRow < 2) { | ||
return; | ||
} | ||
if (perRow < 2) { | ||
return; | ||
} | ||
for (var i = 0, j = items.length; i < j; i += perRow) { | ||
var maxHeight = 0, row = items.slice(i, i + perRow); | ||
for (var i = 0, j = items.length; i < j; i += perRow) { | ||
var maxHeight = 0, row = items.slice(i, i + perRow); | ||
row.each(function() { | ||
var itemHeight = parseFloat($(this).outerHeight()); | ||
row.each(function() { | ||
var itemHeight = parseFloat($(this).outerHeight()); | ||
if (itemHeight > maxHeight) { | ||
maxHeight = itemHeight; | ||
} | ||
}); | ||
if (itemHeight > maxHeight) { | ||
maxHeight = itemHeight; | ||
} | ||
}); | ||
row.css('height', maxHeight); | ||
row.css('height', maxHeight); | ||
} | ||
} | ||
} | ||
$(function() { | ||
var list = $(containerSelector) | ||
.on('reload', reload) | ||
.trigger('reload') | ||
.find('img') | ||
.on('load', function() { | ||
$(this) | ||
.closest(containerSelector) | ||
.trigger('reload') | ||
; | ||
}) | ||
; | ||
$(function() { | ||
var list = $(containerSelector) | ||
.on('reload', reload) | ||
.trigger('reload') | ||
.find('img') | ||
.on('load', function() { | ||
$(this) | ||
.closest(containerSelector) | ||
.trigger('reload') | ||
; | ||
}) | ||
; | ||
$(window).on('resize', function() { | ||
list.trigger('reload'); | ||
$(window).on('resize', function() { | ||
list.trigger('reload'); | ||
}); | ||
}); | ||
}); | ||
}; | ||
}; | ||
})); |
@@ -7,5 +7,6 @@ { | ||
"name": "Jan Sorgalla", | ||
"url": "jan.sorgalla@dotsunited.de" | ||
"email": "jan.sorgalla@dotsunited.de", | ||
"url" : "https://dotsunited.de" | ||
}, | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"repository": { | ||
@@ -12,0 +13,0 @@ "type": "git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57
5055
6