mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
fix: drop hx-trigger once — rely on browser cache for dedup
This commit is contained in:
@@ -21,34 +21,18 @@
|
||||
popover.style.top = top + 'px';
|
||||
}
|
||||
|
||||
// After htmx swaps content in, show and position the popover
|
||||
document.body.addEventListener('htmx:afterSwap', function (e) {
|
||||
if (e.detail.target !== popover) return;
|
||||
popover.hidden = false;
|
||||
if (currentAnchor) position(currentAnchor);
|
||||
});
|
||||
|
||||
// On subsequent hovers (already cached by browser / htmx once),
|
||||
// just reposition and show — htmx won't re-fire due to `once`,
|
||||
// so we handle show/position on mouseenter ourselves.
|
||||
document.body.addEventListener('mouseenter', function (e) {
|
||||
var a = e.target.closest('[data-student-name]');
|
||||
if (!a) return;
|
||||
currentAnchor = a;
|
||||
// If popover already has this student's content, just show it
|
||||
if (popover.dataset.loadedFor === a.dataset.studentName) {
|
||||
position(a);
|
||||
popover.hidden = false;
|
||||
}
|
||||
}, true);
|
||||
|
||||
// Mark which student is loaded after swap
|
||||
document.body.addEventListener('htmx:afterSwap', function (e) {
|
||||
if (e.detail.target !== popover || !currentAnchor) return;
|
||||
popover.dataset.loadedFor = currentAnchor.dataset.studentName;
|
||||
if (e.detail.target !== popover) return;
|
||||
if (currentAnchor) position(currentAnchor);
|
||||
popover.hidden = false;
|
||||
});
|
||||
|
||||
// Hide on mouse leave (both anchor and popover)
|
||||
document.body.addEventListener('mouseleave', function (e) {
|
||||
if (!e.target.closest('[data-student-name]') && !e.target.closest('#student-popover')) return;
|
||||
setTimeout(function () {
|
||||
|
||||
Reference in New Issue
Block a user