aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPeter Chiocchetti2014-12-13 12:38:32 +0100
committerPim van den Berg2014-12-13 12:40:43 +0100
commitbd029dfebd07ae4a6e188e8623cf99b228e5d577 (patch)
tree65ceb9306db00b3e6004b9ee94d648896d1ec51e
parentplugins/ping: show ping_droprate in percentage (diff)
downloadapt-panopticon_cgp-bd029dfebd07ae4a6e188e8623cf99b228e5d577.zip
apt-panopticon_cgp-bd029dfebd07ae4a6e188e8623cf99b228e5d577.tar.gz
apt-panopticon_cgp-bd029dfebd07ae4a6e188e8623cf99b228e5d577.tar.bz2
apt-panopticon_cgp-bd029dfebd07ae4a6e188e8623cf99b228e5d577.tar.xz
js/CGP: scroll wheel zoom center position
Closes #111
-rw-r--r--js/CGP.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/js/CGP.js b/js/CGP.js
index a83380f..5ed729b 100644
--- a/js/CGP.js
+++ b/js/CGP.js
@@ -44,8 +44,10 @@ var CGP = (function() {
44 if (this.stidx < 0) this.stidx = 0; 44 if (this.stidx < 0) this.stidx = 0;
45 } 45 }
46 if (cstime !== this.stime[this.stidx]) { 46 if (cstime !== this.stime[this.stidx]) {
47 var middle = this.rrdgraph.start + Math.abs(Math.round((this.rrdgraph.end - this.rrdgraph.start) / 2)); 47 var posx = e.clientX - e.target.getBoundingClientRect().left - this.rrdgraph.xorigin;
48 this.rrdgraph.start = Math.round(middle - this.stime[this.stidx] / 2); 48 var relx = this.rrdgraph.xsize / Math.min(Math.max(posx, 0), this.rrdgraph.xsize);
49 var cntr = this.rrdgraph.start + Math.abs(Math.round((this.rrdgraph.end - this.rrdgraph.start) / relx));
50 this.rrdgraph.start = Math.round(cntr - this.stime[this.stidx] / relx);
49 this.rrdgraph.end = this.rrdgraph.start + this.stime[this.stidx]; 51 this.rrdgraph.end = this.rrdgraph.start + this.stime[this.stidx];
50 52
51 try { 53 try {