Skip to content

Commit

Permalink
Consider table's border-spacing. Closes #41
Browse files Browse the repository at this point in the history
  • Loading branch information
NeXTs committed Aug 13, 2015
1 parent e53002c commit 5b4ac69
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
8 changes: 7 additions & 1 deletion clusterize.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Clusterize.js - v0.11.0 - 2015-08-08
/*! Clusterize.js - v0.12.0 - 2015-08-14
* http://NeXTs.github.com/Clusterize.js/
* Copyright (c) 2015 Denis Lukov; Licensed MIT */

Expand Down Expand Up @@ -180,6 +180,9 @@
if( ! rows.length) return;
var nodes = this.content_elem.children;
opts.item_height = nodes[Math.ceil(nodes.length / 2)].offsetHeight;
// consider table's border-spacing
if(opts.tag == 'tr' && getStyle('borderCollapse', this.content_elem) != 'collapse')
opts.item_height += parseInt(getStyle('borderSpacing', this.content_elem)) || 0;
opts.block_height = opts.item_height * opts.rows_in_block;
opts.rows_in_cluster = opts.blocks_in_cluster * opts.rows_in_block;
opts.cluster_height = opts.blocks_in_cluster * opts.block_height;
Expand Down Expand Up @@ -295,6 +298,9 @@
function isArray(arr) {
return Object.prototype.toString.call(arr) === '[object Array]';
}
function getStyle(prop, elem) {
return window.getComputedStyle ? window.getComputedStyle(elem)[prop] : elem.currentStyle[prop];
}

return Clusterize;
}));
24 changes: 12 additions & 12 deletions clusterize.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clusterize.js",
"version": "0.11.0",
"version": "0.12.0",
"description": "Tiny vanilla JS plugin to display large data sets easily",
"main": "clusterize.js",
"style": "clusterize.css",
Expand Down

0 comments on commit 5b4ac69

Please sign in to comment.