From 116244c421f6379133d3f2f569fb3321ec690042 Mon Sep 17 00:00:00 2001 From: jos Date: Fri, 24 Jul 2015 11:03:03 +0200 Subject: [PATCH] Fixed #1118: since v4.6.0, grid of time axis was wrongly positioned on some scales --- HISTORY.md | 6 ++++-- lib/timeline/TimeStep.js | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 231caf11..2632f6bf 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -5,8 +5,10 @@ http://visjs.org ### Timeline -- Items keep their group offset while dragging items located in multiple groups. - Thanks @Fice. +- Fixed #192: Items keep their group offset while dragging items located in + multiple groups. Thanks @Fice. +- Fixed #1118: since v4.6.0, grid of time axis was wrongly positioned on some + scales. ## 2015-07-22, version 4.6.0 diff --git a/lib/timeline/TimeStep.js b/lib/timeline/TimeStep.js index 8d14f877..df6301a3 100644 --- a/lib/timeline/TimeStep.js +++ b/lib/timeline/TimeStep.js @@ -164,9 +164,9 @@ TimeStep.prototype.roundToMinor = function() { case 'minute': this.current.subtract(this.current.minutes() % this.step, 'minutes'); break; case 'hour': this.current.subtract(this.current.hours() % this.step, 'hours'); break; case 'weekday': // intentional fall through - case 'day': this.current.subtract((this.current.date() - 1) % this.step); break; - case 'month': this.current.subtract(this.current.month() % this.step); break; - case 'year': this.current.subtract(this.current.year() % this.step); break; + case 'day': this.current.subtract((this.current.date() - 1) % this.step, 'day'); break; + case 'month': this.current.subtract(this.current.month() % this.step, 'month'); break; + case 'year': this.current.subtract(this.current.year() % this.step, 'year'); break; default: break; } } @@ -197,7 +197,7 @@ TimeStep.prototype.next = function() { this.current.add(this.step, 'hour'); // in case of skipping an hour for daylight savings, adjust the hour again (else you get: 0h 5h 9h ... instead of 0h 4h 8h ...) // TODO: is this still needed now we use the function of moment.js? - this.current.subtract(this.current.hours() % this.step); + this.current.subtract(this.current.hours() % this.step, 'hour'); break; case 'weekday': // intentional fall through case 'day': this.current.add(this.step, 'day'); break;