Browse Source

Merge remote-tracking branch 'origin/v4' into v4

Conflicts:
	lib/network/modules/InteractionHandler.js
flowchartTest
Alex de Mulder 9 years ago
parent
commit
ec5f644d12
4 changed files with 34 additions and 3 deletions
  1. +20
    -2
      lib/hammerUtil.js
  2. +5
    -0
      lib/timeline/Core.js
  3. +1
    -1
      lib/timeline/component/ItemSet.js
  4. +8
    -0
      test/timeline.html

+ 20
- 2
lib/hammerUtil.js View File

@ -7,14 +7,23 @@ var Hammer = require('./module/hammer');
*/
exports.onTouch = function (hammer, callback) {
callback.inputHandler = function (event) {
if (event.isFirst) {
if (event.isFirst && !isTouching) {
callback(event);
isTouching = true;
setTimeout(function () {
isTouching = false;
}, 0);
}
};
hammer.on('hammer.input', callback.inputHandler);
};
// isTouching is true while a touch action is being emitted
// this is a hack to prevent `touch` from being fired twice
var isTouching = false;
/**
* Register a release event, taking place after a gesture
* @param {Hammer} hammer A hammer instance
@ -22,13 +31,22 @@ exports.onTouch = function (hammer, callback) {
*/
exports.onRelease = function (hammer, callback) {
callback.inputHandler = function (event) {
if (event.isFinal) {
if (event.isFinal && !isReleasing) {
callback(event);
isReleasing = true;
setTimeout(function () {
isReleasing = false;
}, 0);
}
};
return hammer.on('hammer.input', callback.inputHandler);
};
// isReleasing is true while a release action is being emitted
// this is a hack to prevent `release` from being fired twice
var isReleasing = false;
/**
* Unregister a touch event, taking place before a gesture

+ 5
- 0
lib/timeline/Core.js View File

@ -140,6 +140,11 @@ Core.prototype._create = function (container) {
me.emit('touch', event);
}.bind(this));
// emulate a release event (emitted after a pan, pinch, tap, or press)
hammerUtil.onRelease(this.hammer, function (event) {
me.emit('release', event);
}.bind(this));
function onMouseWheel(event) {
if (me.isActive()) {
me.emit('mousewheel', event);

+ 1
- 1
lib/timeline/component/ItemSet.js View File

@ -1546,7 +1546,7 @@ ItemSet.prototype.groupFromTarget = function(event) {
//}
//
var clientY = event.gesture.center.clientY;
var clientY = event.center.clientY;
for (var i = 0; i < this.groupIds.length; i++) {
var groupId = this.groupIds[i];
var group = this.groups[groupId];

+ 8
- 0
test/timeline.html View File

@ -151,6 +151,14 @@
console.log('select', selection);
});
// timeline.on('touch', function (event) {
// console.log('touch', event, Object.keys(event));
// });
//
// timeline.on('release', function (event) {
// console.log('release', event, Object.keys(event));
// });
/*
timeline.on('rangechange', function (range) {
console.log('rangechange', range);

Loading…
Cancel
Save