Skip to content

Commit

Permalink
v13.6.3
Browse files Browse the repository at this point in the history
Fixed re-positioning issue with tooltips.
  • Loading branch information
boehlerlukas committed Apr 24, 2024
1 parent ee84dfd commit d8073d8
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build/cjs/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/esm/index.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gleap",
"version": "13.6.2",
"version": "13.6.3",
"main": "build/cjs/index.js",
"module": "build/esm/index.mjs",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion published/13.6.2/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion published/latest/index.js

Large diffs are not rendered by default.

41 changes: 30 additions & 11 deletions src/GleapTooltipManager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { arrow, autoPlacement, autoUpdate, computePosition, flip, offset, shift } from '@floating-ui/dom';
import { arrow, autoUpdate, computePosition, flip, offset, shift } from '@floating-ui/dom';
import { GleapSession } from './Gleap';
import { loadIcon } from './UI';

Expand Down Expand Up @@ -33,6 +33,32 @@ export default class GleapTooltipManager {
return this.instance;
}

// Recursive function to process each node and its children
processNodeInsertion(node) {
if (node.nodeType === Node.ELEMENT_NODE) {
// Check the node itself
this.checkNodeTooltip(node);

// Check all children of the node recursively
if (node.childNodes) {
node.childNodes.forEach(childNode => {
this.processNodeInsertion(childNode);
});
}
}
}

// Function to check a single node against the filtered tooltips
checkNodeTooltip(node) {
if (this.filteredTooltips.length > 0) {
this.filteredTooltips.forEach(tooltip => {
if (tooltip.selector && node.matches(tooltip.selector)) {
this.linkTooltip(node, tooltip);
}
});
}
}

start() {
const self = this;

Expand All @@ -51,17 +77,10 @@ export default class GleapTooltipManager {

this.observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
// Check for added nodes
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE) {
if (self.filteredTooltips.length > 0) {
self.filteredTooltips.forEach(tooltip => {
if (tooltip.selector) {
if (node.matches(tooltip.selector)) {
self.linkTooltip(node, tooltip);
}
}
});
}
self.processNodeInsertion(node);
}
});

Expand Down Expand Up @@ -178,7 +197,7 @@ export default class GleapTooltipManager {
setTimeout(() => {
tooltip.style.visibility = 'hidden';
tooltip.style.pointerEvents = 'none';
}, 400);
}, 200);
}, 500);
}

Expand Down
2 changes: 1 addition & 1 deletion src/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export const injectStyledCSS = (
box-shadow: 0px 5px 30px rgba(0, 0, 0, 0.2);
opacity: 0;
visibility: hidden;
transition: opacity 0.4s, visibility 0.4s;
transition: opacity 0.2s, visibility 0.2s;
z-index: ${zIndexBase + 100};
}
Expand Down

0 comments on commit d8073d8

Please sign in to comment.