dasmoth / dalliance

Interactive web-based genome browser.
http://www.biodalliance.org/
BSD 2-Clause "Simplified" License
226 stars 68 forks source link

hover-setTimeout makes hover feel very laggy #232

Closed moritzschaefer closed 6 years ago

moritzschaefer commented 6 years ago
        } else {
            hoverTimeout = setTimeout(function () {
                var hit = featureLookup(rx, ry);
                if (hit && hit.length > 0) {
                    thisB.notifyFeatureHover(ev, hit[hit.length - 1], hit, tier);
                }
            }, 1000);
        }

Is there a reason for this 1 second delay in hover events? When using this feature in the browser, it seems like the application is horribly slow and laggy.

dasmoth commented 6 years ago

The initial motivation for the delay was because the original request that prompted this API was about opening popups when hovering a feature -- and for that, you do want to distinguish between a true "hover" (point and wait) and a pointer over a feature.

c41f68d29caabed84078a80ea42ddb5d7f51a113 adds an extra option when registering a hover listener:

    browser.addFeatureHoverListener(listenerFunction, {immediate: true});

...with this option, your listeners will be notified every time the feature(s) under the pointer change.

Does this help?

moritzschaefer commented 6 years ago

A lot! thank you.