Browse Source

reset switched{Day,Month,Year} in next function, not in isMajor function

codeClimate
Herre Groen 8 years ago
parent
commit
5f7510a7b4
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      lib/timeline/TimeStep.js

+ 6
- 4
lib/timeline/TimeStep.js View File

@ -245,6 +245,11 @@ TimeStep.prototype.next = function() {
this.current = this._end.clone(); this.current = this._end.clone();
} }
// Reset switches for year, month and day. Will get set to true where appropriate in DateUtil.stepOverHiddenDates
this.switchedDay = false;
this.switchedMonth = false;
this.switchedYear = false;
DateUtil.stepOverHiddenDates(this.moment, this, prev); DateUtil.stepOverHiddenDates(this.moment, this, prev);
}; };
@ -443,7 +448,7 @@ TimeStep.snap = function(date, scale, step) {
var _step = step > 5 ? step / 2 : 1; var _step = step > 5 ? step / 2 : 1;
clone.milliseconds(Math.round(clone.milliseconds() / _step) * _step); clone.milliseconds(Math.round(clone.milliseconds() / _step) * _step);
} }
return clone; return clone;
}; };
@ -454,7 +459,6 @@ TimeStep.snap = function(date, scale, step) {
*/ */
TimeStep.prototype.isMajor = function() { TimeStep.prototype.isMajor = function() {
if (this.switchedYear == true) { if (this.switchedYear == true) {
this.switchedYear = false;
switch (this.scale) { switch (this.scale) {
case 'year': case 'year':
case 'month': case 'month':
@ -470,7 +474,6 @@ TimeStep.prototype.isMajor = function() {
} }
} }
else if (this.switchedMonth == true) { else if (this.switchedMonth == true) {
this.switchedMonth = false;
switch (this.scale) { switch (this.scale) {
case 'weekday': case 'weekday':
case 'day': case 'day':
@ -484,7 +487,6 @@ TimeStep.prototype.isMajor = function() {
} }
} }
else if (this.switchedDay == true) { else if (this.switchedDay == true) {
this.switchedDay = false;
switch (this.scale) { switch (this.scale) {
case 'millisecond': case 'millisecond':
case 'second': case 'second':

Loading…
Cancel
Save