Browse Source

Fixed scrolling to zoom not working on IE in standards mode

css_transitions
josdejong 10 years ago
parent
commit
b2cfcc5318
4 changed files with 21 additions and 10 deletions
  1. +6
    -6
      src/graph/Graph.js
  2. +1
    -1
      src/graph/graphMixins/ManipulationMixin.js
  3. +1
    -1
      src/timeline/Range.js
  4. +13
    -2
      src/util.js

+ 6
- 6
src/graph/Graph.js View File

@ -711,7 +711,7 @@ Graph.prototype._getPointer = function (touch) {
* @private
*/
Graph.prototype._onTouch = function (event) {
this.drag.pointer = this._getPointer(event.gesture.touches[0]);
this.drag.pointer = this._getPointer(event.gesture.center);
this.drag.pinched = false;
this.pinch.scale = this._getScale();
@ -797,7 +797,7 @@ Graph.prototype._handleOnDrag = function(event) {
return;
}
var pointer = this._getPointer(event.gesture.touches[0]);
var pointer = this._getPointer(event.gesture.center);
var me = this,
drag = this.drag,
@ -860,7 +860,7 @@ Graph.prototype._onDragEnd = function () {
* @private
*/
Graph.prototype._onTap = function (event) {
var pointer = this._getPointer(event.gesture.touches[0]);
var pointer = this._getPointer(event.gesture.center);
this.pointerPosition = pointer;
this._handleTap(pointer);
@ -872,7 +872,7 @@ Graph.prototype._onTap = function (event) {
* @private
*/
Graph.prototype._onDoubleTap = function (event) {
var pointer = this._getPointer(event.gesture.touches[0]);
var pointer = this._getPointer(event.gesture.center);
this._handleDoubleTap(pointer);
};
@ -883,7 +883,7 @@ Graph.prototype._onDoubleTap = function (event) {
* @private
*/
Graph.prototype._onHold = function (event) {
var pointer = this._getPointer(event.gesture.touches[0]);
var pointer = this._getPointer(event.gesture.center);
this.pointerPosition = pointer;
this._handleOnHold(pointer);
};
@ -894,7 +894,7 @@ Graph.prototype._onHold = function (event) {
* @private
*/
Graph.prototype._onRelease = function (event) {
var pointer = this._getPointer(event.gesture.touches[0]);
var pointer = this._getPointer(event.gesture.center);
this._handleOnRelease(pointer);
};

+ 1
- 1
src/graph/graphMixins/ManipulationMixin.js View File

@ -236,7 +236,7 @@ var manipulationMixin = {
this.cachedFunctions["_handleOnDrag"] = this._handleOnDrag;
this._handleOnDrag = function(event) {
var pointer = this._getPointer(event.gesture.touches[0]);
var pointer = this._getPointer(event.gesture.center);
this.sectors['support']['nodes']['targetNode'].x = this._canvasToX(pointer.x);
this.sectors['support']['nodes']['targetNode'].y = this._canvasToY(pointer.y);
this.sectors['support']['nodes']['targetViaNode'].x = 0.5 * (this._canvasToX(pointer.x) + this.edges['connectionEdge'].from.x);

+ 1
- 1
src/timeline/Range.js View File

@ -394,7 +394,7 @@ Range.prototype._onMouseWheel = function(event, component, direction) {
// calculate center, the date to zoom around
var gesture = util.fakeGesture(this, event),
pointer = getPointer(gesture.touches[0], component.frame),
pointer = getPointer(gesture.center, component.frame),
pointerDate = this._pointerToDate(component, direction, pointer);
this.zoom(scale, pointerDate);

+ 13
- 2
src/util.js View File

@ -542,11 +542,22 @@ util.fakeGesture = function fakeGesture (element, event) {
var eventType = null;
// for hammer.js 1.0.5
return Hammer.event.collectEventData(this, eventType, event);
var gesture = Hammer.event.collectEventData(this, eventType, event);
// for hammer.js 1.0.6
//var touches = Hammer.event.getTouchList(event, eventType);
//return Hammer.event.collectEventData(this, eventType, touches, event);
// var gesture = Hammer.event.collectEventData(this, eventType, touches, event);
// on IE in standards mode, no touches are recognized by hammer.js,
// resulting in NaN values for center.pageX and center.pageY
if (isNaN(gesture.center.pageX)) {
gesture.center.pageX = event.pageX;
}
if (isNaN(gesture.center.pageY)) {
gesture.center.pageY = event.pageY;
}
return gesture;
};
util.option = {};

Loading…
Cancel
Save