Browse Source

Fixed an error thrown when calling timeline.destroy() (see #294)

v3_develop
jos 10 years ago
parent
commit
aaf1afe304
3 changed files with 13 additions and 8 deletions
  1. +1
    -1
      lib/timeline/Core.js
  2. +8
    -4
      lib/timeline/Range.js
  3. +4
    -3
      lib/timeline/component/ItemSet.js

+ 1
- 1
lib/timeline/Core.js View File

@ -100,7 +100,7 @@ Core.prototype._create = function (container) {
// create event listeners for all interesting events, these events will be
// emitted via emitter
this.hammer = Hammer(this.dom.root, {
prevent_default: true
preventDefault: true
});
this.listeners = {};

+ 8
- 4
lib/timeline/Range.js View File

@ -360,14 +360,18 @@ Range.prototype._onDrag = function (event) {
if (!this.options.moveable) return;
var direction = this.options.direction;
validateDirection(direction);
// refuse to drag when we where pinching to prevent the timeline make a jump
// when releasing the fingers in opposite order from the touch screen
if (!this.props.touch.allowDragging) return;
var delta = (direction == 'horizontal') ? event.gesture.deltaX : event.gesture.deltaY,
interval = (this.props.touch.end - this.props.touch.start),
width = (direction == 'horizontal') ? this.body.domProps.center.width : this.body.domProps.center.height,
diffRange = -delta / width * interval;
var delta = (direction == 'horizontal') ? event.gesture.deltaX : event.gesture.deltaY;
var interval = (this.props.touch.end - this.props.touch.start);
var width = (direction == 'horizontal') ? this.body.domProps.center.width : this.body.domProps.center.height;
var diffRange = -delta / width * interval;
this._applyRange(this.props.touch.start + diffRange, this.props.touch.end + diffRange);
// fire a rangechange event
this.body.emitter.emit('rangechange', {
start: new Date(this.start),
end: new Date(this.end)

+ 4
- 3
lib/timeline/component/ItemSet.js View File

@ -48,10 +48,10 @@ function ItemSet(body, options) {
onMove: function (item, callback) {
callback(item);
},
onMoving: null,
onRemove: function (item, callback) {
callback(item);
},
onMoving: null, // onMoving is null by default for better performance (other on* functions do not support null)
margin: {
item: {
@ -299,8 +299,8 @@ ItemSet.prototype.setOptions = function(options) {
// callback functions
var addCallback = (function (name) {
if (name in options) {
var fn = options[name];
var fn = options[name];
if (fn) {
if (!(fn instanceof Function)) {
throw new Error('option ' + name + ' must be a function ' + name + '(item, callback)');
}
@ -1157,6 +1157,7 @@ ItemSet.prototype._onDrag = function (event) {
* @private
*/
ItemSet.prototype._updateItemProps = function(item, props) {
// TODO: copy all properties from props to item? (also new ones)
if ('start' in props) item.data.start = props.start;
if ('end' in props) item.data.end = props.end;
if ('group' in props && item.data.group != props.group) {

Loading…
Cancel
Save