Browse Source

Fixed broken method `getEventProperties`

flowchartTest
jos 9 years ago
parent
commit
97de69af1c
2 changed files with 12 additions and 8 deletions
  1. +5
    -3
      lib/timeline/Graph2d.js
  2. +7
    -5
      lib/timeline/Timeline.js

+ 5
- 3
lib/timeline/Graph2d.js View File

@ -251,12 +251,14 @@ Graph2d.prototype.getItemRange = function() {
* The event happened, whether clicked on an item, etc.
*/
Graph2d.prototype.getEventProperties = function (event) {
var pageX = event.gesture ? event.gesture.center.pageX : event.pageX;
var pageY = event.gesture ? event.gesture.center.pageY : event.pageY;
var pageX = event.center ? event.center.x : event.pageX;
var pageY = event.center ? event.center.y : event.pageY;
var x = pageX - util.getAbsoluteLeft(this.dom.centerContainer);
var y = pageY - util.getAbsoluteTop(this.dom.centerContainer);
var time = this._toTime(x);
var customTime = CustomTime.customTimeFromTarget(event);
var element = util.getTarget(event);
var what = null;
if (util.hasParent(element, this.timeAxis.dom.foreground)) {what = 'axis';}
@ -265,7 +267,7 @@ Graph2d.prototype.getEventProperties = function (event) {
else if (util.hasParent(element, this.linegraph.yAxisRight.dom.frame)) {what = 'data-axis';}
else if (util.hasParent(element, this.linegraph.legendLeft.dom.frame)) {what = 'legend';}
else if (util.hasParent(element, this.linegraph.legendRight.dom.frame)) {what = 'legend';}
else if (CustomTime.customTimeFromTarget(event) != null) {what = 'custom-time';}
else if (customTime != null) {what = 'custom-time';}
else if (util.hasParent(element, this.currentTime.bar)) {what = 'current-time';}
else if (util.hasParent(element, this.dom.center)) {what = 'background';}

+ 7
- 5
lib/timeline/Timeline.js View File

@ -338,13 +338,15 @@ Timeline.prototype.getItemRange = function() {
* The event happened, whether clicked on an item, etc.
*/
Timeline.prototype.getEventProperties = function (event) {
var item = this.itemSet.itemFromTarget(event);
var group = this.itemSet.groupFromTarget(event);
var pageX = event.gesture ? event.gesture.center.pageX : event.pageX;
var pageY = event.gesture ? event.gesture.center.pageY : event.pageY;
var pageX = event.center ? event.center.x : event.pageX;
var pageY = event.center ? event.center.y : event.pageY;
var x = pageX - util.getAbsoluteLeft(this.dom.centerContainer);
var y = pageY - util.getAbsoluteTop(this.dom.centerContainer);
var item = this.itemSet.itemFromTarget(event);
var group = this.itemSet.groupFromTarget(event);
var customTime = CustomTime.customTimeFromTarget(event);
var snap = this.itemSet.options.snap || null;
var scale = this.body.util.getScale();
var step = this.body.util.getStep();
@ -354,10 +356,10 @@ Timeline.prototype.getEventProperties = function (event) {
var element = util.getTarget(event);
var what = null;
if (item != null) {what = 'item';}
else if (customTime != null) {what = 'custom-time';}
else if (util.hasParent(element, this.timeAxis.dom.foreground)) {what = 'axis';}
else if (this.timeAxis2 && util.hasParent(element, this.timeAxis2.dom.foreground)) {what = 'axis';}
else if (util.hasParent(element, this.itemSet.dom.labelSet)) {what = 'group-label';}
else if (CustomTime.customTimeFromTarget(event) != null) {what = 'custom-time';}
else if (util.hasParent(element, this.currentTime.bar)) {what = 'current-time';}
else if (util.hasParent(element, this.dom.center)) {what = 'background';}

Loading…
Cancel
Save