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 // create event listeners for all interesting events, these events will be
// emitted via emitter // emitted via emitter
this.hammer = Hammer(this.dom.root, { this.hammer = Hammer(this.dom.root, {
prevent_default: true
preventDefault: true
}); });
this.listeners = {}; this.listeners = {};

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

@ -360,14 +360,18 @@ Range.prototype._onDrag = function (event) {
if (!this.options.moveable) return; if (!this.options.moveable) return;
var direction = this.options.direction; var direction = this.options.direction;
validateDirection(direction); validateDirection(direction);
// refuse to drag when we where pinching to prevent the timeline make a jump // 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 // when releasing the fingers in opposite order from the touch screen
if (!this.props.touch.allowDragging) return; 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); this._applyRange(this.props.touch.start + diffRange, this.props.touch.end + diffRange);
// fire a rangechange event
this.body.emitter.emit('rangechange', { this.body.emitter.emit('rangechange', {
start: new Date(this.start), start: new Date(this.start),
end: new Date(this.end) 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) { onMove: function (item, callback) {
callback(item); callback(item);
}, },
onMoving: null,
onRemove: function (item, callback) { onRemove: function (item, callback) {
callback(item); callback(item);
}, },
onMoving: null, // onMoving is null by default for better performance (other on* functions do not support null)
margin: { margin: {
item: { item: {
@ -299,8 +299,8 @@ ItemSet.prototype.setOptions = function(options) {
// callback functions // callback functions
var addCallback = (function (name) { var addCallback = (function (name) {
if (name in options) {
var fn = options[name];
var fn = options[name];
if (fn) {
if (!(fn instanceof Function)) { if (!(fn instanceof Function)) {
throw new Error('option ' + name + ' must be a function ' + name + '(item, callback)'); throw new Error('option ' + name + ' must be a function ' + name + '(item, callback)');
} }
@ -1157,6 +1157,7 @@ ItemSet.prototype._onDrag = function (event) {
* @private * @private
*/ */
ItemSet.prototype._updateItemProps = function(item, props) { 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 ('start' in props) item.data.start = props.start;
if ('end' in props) item.data.end = props.end; if ('end' in props) item.data.end = props.end;
if ('group' in props && item.data.group != props.group) { if ('group' in props && item.data.group != props.group) {

Loading…
Cancel
Save