Skip to content

Commit

Permalink
Implemented scrollingProgress callback and getScrollProgress method. C…
Browse files Browse the repository at this point in the history
…loses #44 #48
  • Loading branch information
NeXTs committed Nov 11, 2015
1 parent d89eee2 commit 2878963
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
14 changes: 11 additions & 3 deletions clusterize.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Clusterize.js - v0.13.0 - 2015-11-10
/*! Clusterize.js - v0.14.0 - 2015-11-11
* http://NeXTs.github.com/Clusterize.js/
* Copyright (c) 2015 Denis Lukov; Licensed MIT */

Expand Down Expand Up @@ -41,7 +41,8 @@
no_data_text: 'No data',
keep_parity: true,
verify_change: false,
callbacks: {}
callbacks: {},
scroll_top: 0
}

// public parameters
Expand Down Expand Up @@ -99,6 +100,8 @@
}
if (last_cluster != (last_cluster = self.getClusterNum()))
self.insertToDOM(rows, cache);
if (self.options.callbacks.scrollingProgress)
self.options.callbacks.scrollingProgress(self.getScrollProgress());
},
resize_debounce = 0,
resizeEv = function() {
Expand Down Expand Up @@ -136,6 +139,10 @@
self.getRowsAmount = function() {
return rows.length;
}
self.getScrollProgress = function() {
return this.options.scroll_top / (rows.length * this.options.item_height) * 100 || 0;
}

var add = function(where, _new_rows) {
var new_rows = isArray(_new_rows)
? _new_rows
Expand Down Expand Up @@ -191,7 +198,8 @@
},
// get current cluster number
getClusterNum: function () {
return Math.floor(this.scroll_elem.scrollTop / (this.options.cluster_height - this.options.block_height)) || 0;
this.options.scroll_top = this.scroll_elem.scrollTop;
return Math.floor(this.options.scroll_top / (this.options.cluster_height - this.options.block_height)) || 0;
},
// generate empty row if no data provided
generateEmptyRow: function() {
Expand Down
21 changes: 11 additions & 10 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.13.0",
"version": "0.14.0",
"description": "Tiny vanilla JS plugin to display large data sets easily",
"main": "clusterize.js",
"style": "clusterize.css",
Expand Down

0 comments on commit 2878963

Please sign in to comment.