Introduction
Introduction Statistics Contact Development Disclaimer Help
datatable improvements - jscancer - Javascript crap (relatively small)
git clone git://git.codemadness.org/jscancer
Log
Files
Refs
README
LICENSE
---
commit 87c20268ba0558928ae28e6a59d130f14fac7795
parent 8803e0fdca023fa927652585137eb5607355e357
Author: Hiltjo Posthuma <[email protected]>
Date: Sun, 2 Oct 2016 13:26:29 +0200
datatable improvements
- in lazyscroll mode: reset scroll position after filtering.
- in lazyscroll mode: on window resize also call scroll(): this will force
to redraw the table (fixes a glitch).
- increase scroll update interval (~30fps to ~60fps) to be a bit smoother.
Diffstat:
M datatable/datatable.js | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/datatable/datatable.js b/datatable/datatable.js
@@ -108,23 +108,24 @@ function datatable_init(el) {
for (var i = start, prev = startfiller, p = bodytbody;…
prev = p.insertBefore(d.data[i].tr, prev.nextS…
};
+ d.scroll = function(y) {
+ bodyel.scrollTop = y;
+ };
- var curscrollleft, curscrolltop, verticalscrolltimer;
- bodyel.addEventListener("scroll", function() {
+ var curscrollleft, verticalscrolltimer;
+ var scroll = function() {
// handle left / right scroll.
var scrolleft = bodyel.scrollLeft;
if (curscrollleft !== scrolleft)
headersel.scrollLeft = curscrollleft = scrolle…
// handle up/down scroll.
- var scrolltop = bodyel.scrollTop;
- if (curscrolltop !== scrolltop) {
- clearTimeout(verticalscrolltimer);
- verticalscrolltimer = setTimeout(function() {
- d.display(d.data);
- }, 32);
- curscrolltop = scrolltop;
- }
- });
+ clearTimeout(verticalscrolltimer);
+ verticalscrolltimer = setTimeout(function() {
+ d.display(d.data);
+ }, 16);
+ };
+ window.addEventListener("resize", scroll);
+ bodyel.addEventListener("scroll", scroll);
d.display(d.data);
} else {
d.display = function(data) {
@@ -264,6 +265,8 @@ function datatable_filter_text(d, s) {
}
d.search = s;
d.display(d.data);
+ if (d.scroll)
+ d.scroll(0);
}
function datatable_filter_delayed(d, fn, e) {
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.