Browse Source

Add a new moveTo function to range to allow a program to recenter the

timeline on any given date.
css_transitions
Eric Gillingham 11 years ago
parent
commit
3c5983c78c
1 changed files with 16 additions and 0 deletions
  1. +16
    -0
      src/timeline/Range.js

+ 16
- 0
src/timeline/Range.js View File

@ -522,3 +522,19 @@ Range.prototype.move = function(moveFactor) {
this.start = newStart; this.start = newStart;
this.end = newEnd; this.end = newEnd;
}; };
/**
* Move the range to a new center point
* @param {Number} moveTo New center point of the range
*/
Range.prototype.moveTo = function(moveTo) {
var center = (this.start + this.end) / 2;
var diff = center - moveTo;
// calculate new start and end
var newStart = this.start - diff;
var newEnd = this.end - diff;
this.setRange(newStart, newEnd);
}

Loading…
Cancel
Save