Browse Source

Update ItemSet.js (#4238)

Delay the tooltip popup on items for 500ms.
develop
daRoof 5 years ago
committed by Alexander Wunschik
parent
commit
9de41d6f91
1 changed files with 40 additions and 1 deletions
  1. +40
    -1
      lib/timeline/component/ItemSet.js

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

@ -192,6 +192,7 @@ function ItemSet(body, options) {
this.selection = []; // list with the ids of all selected nodes
this.popup = null;
this.popupTimer = null;
this.touchParams = {}; // stores properties while dragging
this.groupTouchParams = {};
@ -480,6 +481,8 @@ ItemSet.prototype.markDirty = function(options) {
* Destroy the ItemSet
*/
ItemSet.prototype.destroy = function() {
this.clearPopupTimer();
this.hide();
this.setItems(null);
this.setGroups(null);
@ -536,6 +539,29 @@ ItemSet.prototype.show = function() {
}
};
/**
* Activates the popup timer to show the given popup after a fixed time.
*/
ItemSet.prototype.setPopupTimer = function (popup) {
this.clearPopupTimer();
if (popup) {
this.popupTimer = setTimeout(
function () {
popup.show()
}, 500);
}
};
/**
* Clears the popup timer for the tooltip.
*/
ItemSet.prototype.clearPopupTimer = function () {
if (this.popupTimer != null) {
clearTimeout(this.popupTimer);
this.popupTimer = null;
}
};
/**
* Set selected items by their id. Replaces the current selection
* Unknown id's are silently ignored.
@ -1533,6 +1559,12 @@ ItemSet.prototype._onDragStartAddItem = function (event) {
* @private
*/
ItemSet.prototype._onDrag = function (event) {
// deactivate tooltip window
this.clearPopupTimer();
if (this.popup != null) {
this.popup.hide();
}
if (this.touchParams.itemProps) {
event.stopPropagation();
@ -2016,10 +2048,11 @@ ItemSet.prototype._onMouseOver = function (event) {
event.clientX - util.getAbsoluteLeft(container) + container.offsetLeft,
event.clientY - util.getAbsoluteTop(container) + container.offsetTop
);
this.popup.show();
this.setPopupTimer(this.popup);
} else {
// Hovering over item without a title, hide popup
// Needed instead of _just_ in _onMouseOut due to #2572
this.clearPopupTimer();
if (this.popup != null) {
this.popup.hide();
}
@ -2041,6 +2074,7 @@ ItemSet.prototype._onMouseOut = function (event) {
return;
}
this.clearPopupTimer();
if (this.popup != null) {
this.popup.hide();
}
@ -2054,6 +2088,11 @@ ItemSet.prototype._onMouseMove = function (event) {
var item = this.itemFromTarget(event);
if (!item) return;
if (this.popupTimer != null) {
// restart timer
this.setPopupTimer(this.popup);
}
if (this.options.showTooltips && this.options.tooltip.followMouse) {
if (this.popup) {
if (!this.popup.hidden) {

Loading…
Cancel
Save