| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,6 +51,7 @@ | |||
| 51 | 51 | import static org.jboss.elemento.EventType.focusout; | |
| 52 | 52 | import static org.jboss.elemento.EventType.mouseenter; | |
| 53 | 53 | import static org.jboss.elemento.EventType.mouseleave; | |
| 54 | + import static org.jboss.elemento.EventType.scroll; | ||
| 54 | 55 | import static org.patternfly.component.tooltip.TriggerAria.describedBy; | |
| 55 | 56 | import static org.patternfly.component.tooltip.TriggerAria.none; | |
| 56 | 57 | import static org.patternfly.core.Aria.live; | |
@@ -138,6 +139,7 @@ public static Tooltip2 tooltip2(Supplier<HTMLElement> trigger, String text) { | |||
| 138 | 139 | private TriggerAria aria; | |
| 139 | 140 | private HandlerRegistration triggerHandlers; | |
| 140 | 141 | private HandlerRegistration anchorHandlers; | |
| 142 | + private HandlerRegistration scrollHandler; | ||
| 141 | 143 | ||
| 142 | 144 | Tooltip2(Supplier<HTMLElement> trigger, String text) { | |
| 143 | 145 | super(ComponentType.Tooltip2, div().css(component(tooltip)) | |
@@ -205,6 +207,9 @@ public void attach(MutationRecord mutationRecord) { | |||
| 205 | 207 | anchorHandlers = compose( | |
| 206 | 208 | bind(element(), mouseenter, this::cancelTimers), | |
| 207 | 209 | bind(element(), mouseleave, this::scheduleHide)); | |
| 210 | + | ||
| 211 | + // hide tooltip immediately on scroll to prevent jump artifacts | ||
| 212 | + scrollHandler = bind(window, scroll.name, this::hideOnScroll); | ||
| 208 | 213 | } else { | |
| 209 | 214 | logger.error("Unable to find trigger element for tooltip %o", element()); | |
| 210 | 215 | } | |
@@ -220,6 +225,9 @@ public void detach(MutationRecord mutationRecord) { | |||
| 220 | 225 | element().hidePopover(); | |
| 221 | 226 | visible = false; | |
| 222 | 227 | } | |
| 228 | + if (scrollHandler != null) { | ||
| 229 | + scrollHandler.removeHandler(); | ||
| 230 | + } | ||
| 223 | 231 | if (anchorHandlers != null) { | |
| 224 | 232 | anchorHandlers.removeHandler(); | |
| 225 | 233 | } | |
@@ -352,6 +360,13 @@ private void scheduleHide(Event event) { | |||
| 352 | 360 | hideTimeout = setTimeout(e -> close(new Event(""), true), exitDelay); | |
| 353 | 361 | } | |
| 354 | 362 | ||
| 363 | + private void hideOnScroll(Event event) { | ||
| 364 | + cancelTimers(event); | ||
| 365 | + if (visible) { | ||
| 366 | + close(event, true); | ||
| 367 | + } | ||
| 368 | + } | ||
| 369 | + | ||
| 355 | 370 | private void cancelTimers(Event event) { | |
| 356 | 371 | clearTimeout(showTimeout); | |
| 357 | 372 | clearTimeout(hideTimeout); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments