diff --git a/src/timeline/Timeline.js b/src/timeline/Timeline.js index a54a8a76..a2c4ceb0 100644 --- a/src/timeline/Timeline.js +++ b/src/timeline/Timeline.js @@ -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); diff --git a/src/timeline/component/ItemSet.js b/src/timeline/component/ItemSet.js index 9ba812ee..fb1fce19 100644 --- a/src/timeline/component/ItemSet.js +++ b/src/timeline/component/ItemSet.js @@ -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; }