Browse Source

Fixed preventDefault issue with hammer.js (a brute force solution but lets see how it goes...)

flowchartTest
jos 9 years ago
parent
commit
88a9149369
7 changed files with 8 additions and 32 deletions
  1. +3
    -1
      lib/module/hammer.js
  2. +0
    -6
      lib/timeline/Range.js
  3. +4
    -6
      lib/timeline/component/CustomTime.js
  4. +0
    -3
      lib/timeline/component/ItemSet.js
  5. +0
    -1
      lib/timeline/component/item/Item.js
  6. +0
    -14
      lib/timeline/component/item/RangeItem.js
  7. +1
    -1
      package.json

+ 3
- 1
lib/module/hammer.js View File

@ -3,7 +3,9 @@
if (typeof window !== 'undefined') { if (typeof window !== 'undefined') {
var propagating = require('propagating-hammerjs'); var propagating = require('propagating-hammerjs');
var Hammer = window['Hammer'] || require('hammerjs'); var Hammer = window['Hammer'] || require('hammerjs');
module.exports = propagating(Hammer);
module.exports = propagating(Hammer, {
preventDefault: true
});
} }
else { else {
module.exports = function () { module.exports = function () {

+ 0
- 6
lib/timeline/Range.js View File

@ -368,8 +368,6 @@ Range.prototype._onDragStart = function(event) {
if (this.body.dom.root) { if (this.body.dom.root) {
this.body.dom.root.style.cursor = 'move'; this.body.dom.root.style.cursor = 'move';
} }
event.preventDefault();
}; };
/** /**
@ -421,8 +419,6 @@ Range.prototype._onDrag = function (event) {
end: new Date(this.end), end: new Date(this.end),
byUser: true byUser: true
}); });
event.preventDefault();
}; };
/** /**
@ -565,8 +561,6 @@ Range.prototype._onPinch = function (event) {
this.startToFront = false; // revert to default this.startToFront = false; // revert to default
this.endToFront = true; // revert to default this.endToFront = true; // revert to default
event.preventDefault();
}; };
/** /**

+ 4
- 6
lib/timeline/component/CustomTime.js View File

@ -83,9 +83,10 @@ CustomTime.prototype._create = function() {
this.hammer.on('panstart', this._onDragStart.bind(this)); this.hammer.on('panstart', this._onDragStart.bind(this));
this.hammer.on('panmove', this._onDrag.bind(this)); this.hammer.on('panmove', this._onDrag.bind(this));
this.hammer.on('panend', this._onDragEnd.bind(this)); this.hammer.on('panend', this._onDragEnd.bind(this));
this.hammer.on('pan', function (event) {
event.preventDefault();
});
// TODO: cleanup
//this.hammer.on('pan', function (event) {
// event.preventDefault();
//});
}; };
/** /**
@ -162,7 +163,6 @@ CustomTime.prototype._onDragStart = function(event) {
this.eventParams.customTime = this.customTime; this.eventParams.customTime = this.customTime;
event.stopPropagation(); event.stopPropagation();
event.preventDefault();
}; };
/** /**
@ -185,7 +185,6 @@ CustomTime.prototype._onDrag = function (event) {
}); });
event.stopPropagation(); event.stopPropagation();
event.preventDefault();
}; };
/** /**
@ -203,7 +202,6 @@ CustomTime.prototype._onDragEnd = function (event) {
}); });
event.stopPropagation(); event.stopPropagation();
event.preventDefault();
}; };
module.exports = CustomTime; module.exports = CustomTime;

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

@ -1167,7 +1167,6 @@ ItemSet.prototype._onDragStart = function (event) {
} }
event.stopPropagation(); event.stopPropagation();
event.preventDefault();
} }
}; };
@ -1177,8 +1176,6 @@ ItemSet.prototype._onDragStart = function (event) {
* @private * @private
*/ */
ItemSet.prototype._onDrag = function (event) { ItemSet.prototype._onDrag = function (event) {
event.preventDefault();
if (this.touchParams.itemProps) { if (this.touchParams.itemProps) {
var me = this; var me = this;
var snap = this.options.snap || null; var snap = this.options.snap || null;

+ 0
- 1
lib/timeline/component/item/Item.js View File

@ -141,7 +141,6 @@ Item.prototype._repaintDeleteButton = function (anchor) {
new Hammer(deleteButton).on('tap', function (event) { new Hammer(deleteButton).on('tap', function (event) {
me.parent.removeFromDataSet(me); me.parent.removeFromDataSet(me);
event.stopPropagation(); event.stopPropagation();
event.preventDefault();
}); });
anchor.appendChild(deleteButton); anchor.appendChild(deleteButton);

+ 0
- 14
lib/timeline/component/item/RangeItem.js View File

@ -249,13 +249,6 @@ RangeItem.prototype._repaintDragLeft = function () {
dragLeft.className = 'drag-left'; dragLeft.className = 'drag-left';
dragLeft.dragLeftItem = this; dragLeft.dragLeftItem = this;
//// TODO: this should be redundant?
//Hammer(dragLeft, {
// preventDefault: true
//}).on('drag', function () {
// //console.log('drag left')
// });
this.dom.box.appendChild(dragLeft); this.dom.box.appendChild(dragLeft);
this.dom.dragLeft = dragLeft; this.dom.dragLeft = dragLeft;
} }
@ -279,13 +272,6 @@ RangeItem.prototype._repaintDragRight = function () {
dragRight.className = 'drag-right'; dragRight.className = 'drag-right';
dragRight.dragRightItem = this; dragRight.dragRightItem = this;
//// TODO: this should be redundant?
//Hammer(dragRight, {
// preventDefault: true
//}).on('drag', function () {
// //console.log('drag right')
//});
this.dom.box.appendChild(dragRight); this.dom.box.appendChild(dragRight);
this.dom.dragRight = dragRight; this.dom.dragRight = dragRight;
} }

+ 1
- 1
package.json View File

@ -32,7 +32,7 @@
"hammerjs": "^2.0.4", "hammerjs": "^2.0.4",
"keycharm": "^0.2.0", "keycharm": "^0.2.0",
"moment": "^2.9.0", "moment": "^2.9.0",
"propagating-hammerjs": "^1.2.0"
"propagating-hammerjs": "^1.3.0"
}, },
"devDependencies": { "devDependencies": {
"6to5": "^3.5.3", "6to5": "^3.5.3",

Loading…
Cancel
Save