add delay to desc/tag in en mouse events

This commit is contained in:
Vladimir Mandic
2023-09-07 14:14:07 -04:00
parent ee40033c8e
commit 5712a8cb20
+14 -8
View File
@@ -162,15 +162,21 @@ function setupExtraNetworksForTab(tabname) {
});
});
let hoverTimer = null;
gradioApp().getElementById(`${tabname}_extra_tabs`).onmouseover = (e) => {
const el = e?.target?.parentElement;
if (!el?.classList?.contains('card')) return;
if (el.title === previousCard) return;
readCardDescription(el.dataset.filename, el.dataset.description);
readCardTags(el, el.dataset.tags);
e.stopPropagation();
e.preventDefault();
previousCard = el.title;
const el = e.target.closest('.card'); // bubble-up to card
if (!el || (el.title === previousCard)) return;
if (!hoverTimer) {
hoverTimer = setTimeout(() => {
readCardDescription(el.dataset.filename, el.dataset.description);
readCardTags(el, el.dataset.tags);
previousCard = el.title;
}, 300);
}
el.onmouseout = () => {
clearTimeout(hoverTimer);
hoverTimer = null;
};
};
const intersectionObserver = new IntersectionObserver((entries) => {