Browse Source

Fixed date snapping

css_transitions
jos 10 years ago
parent
commit
2723b2673a
2 changed files with 3 additions and 2 deletions
  1. +1
    -0
      src/timeline/Timeline.js
  2. +2
    -2
      src/timeline/component/ItemSet.js

+ 1
- 0
src/timeline/Timeline.js View File

@ -99,6 +99,7 @@ function Timeline (container, items, options) {
// time axis
this.timeAxis = new TimeAxis(this, this.options);
this.components.push(this.timeAxis);
this.options.snap = this.timeAxis.snap.bind(this.timeAxis); // TODO: not nice adding snap to options
// current time bar
this.currentTime = new CurrentTime(this, this.options);

+ 2
- 2
src/timeline/component/ItemSet.js View File

@ -1076,7 +1076,7 @@ ItemSet.prototype._onAddItem = function (event) {
// add item
var xAbs = vis.util.getAbsoluteLeft(this.dom.frame);
var x = event.gesture.center.pageX - xAbs;
var start = this._toTime(x);
var start = this.options.toTime(x);
var newItem = {
start: snap ? snap(start) : start,
content: 'new item'
@ -1084,7 +1084,7 @@ ItemSet.prototype._onAddItem = function (event) {
// when default type is a range, add a default end date to the new item
if (this.options.type === 'range' || this.options.type == 'rangeoverflow') {
var end = this._toTime(x + this.props.width / 5);
var end = this.options.toTime(x + this.props.width / 5);
newItem.end = snap ? snap(end) : end;
}

Loading…
Cancel
Save