Skip to content

Commit

Permalink
Handle hidden lists. Closes #100
Browse files Browse the repository at this point in the history
  • Loading branch information
NeXTs committed Mar 5, 2017
1 parent 973efb7 commit 569c029
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
14 changes: 6 additions & 8 deletions clusterize.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Clusterize.js - v0.17.5 - 2017-02-25
/*! Clusterize.js - v0.17.6 - 2017-03-05
* http://NeXTs.github.com/Clusterize.js/
* Copyright (c) 2015 Denis Lukov; Licensed GPLv3 */

Expand Down Expand Up @@ -63,7 +63,7 @@
var rows = isArray(data.rows)
? data.rows
: self.fetchMarkup(),
cache = {data: '', top: 0, bottom: 0},
cache = {},
scroll_top = self.scroll_elem.scrollTop;

// append initial data
Expand Down Expand Up @@ -161,24 +161,22 @@
return rows;
},
// get tag name, content tag name, tag height, calc cluster height
exploreEnvironment: function(rows) {
exploreEnvironment: function(rows, cache) {
var opts = this.options;
opts.content_tag = this.content_elem.tagName.toLowerCase();
if( ! rows.length) return;
if(ie && ie <= 9 && ! opts.tag) opts.tag = rows[0].match(/<([^>\s/]*)/)[1].toLowerCase();
if(this.content_elem.children.length <= 1) this.html(rows[0] + rows[0] + rows[0]);
if(this.content_elem.children.length <= 1) cache.data = this.html(rows[0] + rows[0] + rows[0]);
if( ! opts.tag) opts.tag = this.content_elem.children[0].tagName.toLowerCase();
this.getRowsHeight(rows);
},
getRowsHeight: function(rows) {
var opts = this.options,
prev_item_height = opts.item_height;
opts.cluster_height = 0
opts.cluster_height = 0;
if( ! rows.length) return;
var nodes = this.content_elem.children;
var node = nodes[Math.floor(nodes.length / 2)];
// don't measure height if element is hidden. fixes #98
if( ! node.offsetParent) return;
opts.item_height = node.offsetHeight;
// consider table's border-spacing
if(opts.tag == 'tr' && getStyle('borderCollapse', this.content_elem) != 'collapse')
Expand Down Expand Up @@ -257,7 +255,7 @@
insertToDOM: function(rows, cache) {
// explore row's height
if( ! this.options.cluster_height) {
this.exploreEnvironment(rows);
this.exploreEnvironment(rows, cache);
}
var data = this.generate(rows, this.getClusterNum()),
this_cluster_rows = data.rows.join(''),
Expand Down
22 changes: 11 additions & 11 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.17.5",
"version": "0.17.6",
"description": "Tiny vanilla JS plugin to display large data sets easily",
"main": "clusterize.js",
"style": "clusterize.css",
Expand Down

0 comments on commit 569c029

Please sign in to comment.