Browse Source

mouseup and mousedown events fixes #3032 (#3059)

* mouseup and mousedown events

* Fix error
gemini
Danny Larsen 7 years ago
committed by yotamberk
parent
commit
63794a32d8
4 changed files with 57 additions and 4 deletions
  1. +27
    -0
      docs/timeline/index.html
  2. +8
    -0
      examples/timeline/interaction/eventListeners.html
  3. +21
    -3
      lib/timeline/Timeline.js
  4. +1
    -1
      lib/timeline/component/ItemSet.js

+ 27
- 0
docs/timeline/index.html View File

@ -1584,6 +1584,33 @@ timeline.off('select', onSelect);
</td>
</tr>
<tr>
<td>mouseDown</td>
<td>
Passes a properties object as returned by the method <a href="#getEventProperties"><code>Timeline.getEventProperties(event)</code></a>.
</td>
<td>Fired when the mouse down event is triggered over a timeline element.
</td>
</tr>
<tr>
<td>mouseUp</td>
<td>
Passes a properties object as returned by the method <a href="#getEventProperties"><code>Timeline.getEventProperties(event)</code></a>.
</td>
<td>Fired when the mouse up event is triggered over a timeline element.
</td>
</tr>
<tr>
<td>mouseMove</td>
<td>
Passes a properties object as returned by the method <a href="#getEventProperties"><code>Timeline.getEventProperties(event)</code></a>.
</td>
<td>Fired when the mouse is moved over a timeline element.
</td>
</tr>
<tr>
<td>groupDragged</td>
<td>

+ 8
- 0
examples/timeline/interaction/eventListeners.html View File

@ -72,6 +72,14 @@
logEvent('contextmenu', properties);
});
timeline.on('mouseDown', function (properties) {
logEvent('mouseDown', properties);
});
timeline.on('mouseUp', function (properties) {
logEvent('mouseUp', properties);
});
// other possible events:
// timeline.on('mouseOver', function (properties) {

+ 21
- 3
lib/timeline/Timeline.js View File

@ -139,9 +139,27 @@ function Timeline (container, items, groups, options) {
this.dom.root.onmouseover = function (event) {
me.emit('mouseOver', me.getEventProperties(event))
};
this.dom.root.onmousemove = function (event) {
me.emit('mouseMove', me.getEventProperties(event))
};
if(window.PointerEvent) {
this.dom.root.onpointerdown = function (event) {
me.emit('mouseDown', me.getEventProperties(event))
};
this.dom.root.onpointermove = function (event) {
me.emit('mouseMove', me.getEventProperties(event))
};
this.dom.root.onpointerup = function (event) {
me.emit('mouseUp', me.getEventProperties(event))
};
} else {
this.dom.root.onmousemove = function (event) {
me.emit('mouseMove', me.getEventProperties(event))
};
this.dom.root.onmousedown = function (event) {
me.emit('mouseDown', me.getEventProperties(event))
};
this.dom.root.onmouseup = function (event) {
me.emit('mouseUp', me.getEventProperties(event))
};
}
//Single time autoscale/fit
this.fitDone = false;

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

@ -2220,7 +2220,7 @@ ItemSet.prototype.groupFromTarget = function(event) {
var clientY = event.center ? event.center.y : event.clientY;
var groupIds = this.groupIds;
if (groupIds.length <= 0) {
if (groupIds.length <= 0 && this.groupsData) {
groupIds = this.groupsData.getIds({
order: this.options.groupOrder
});

Loading…
Cancel
Save