Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip position calculation on scroll if tooltip is not displayed #835

Closed
ladariha opened this issue Mar 9, 2022 · 3 comments
Closed

Skip position calculation on scroll if tooltip is not displayed #835

ladariha opened this issue Mar 9, 2022 · 3 comments
Labels

Comments

@ladariha
Copy link

ladariha commented Mar 9, 2022

I have a long list of items (~1000), each item has let's say <10 tooltips made with v-tooltip:

app.use(FloatingVue, {
            themes: {
                "info-tooltip": {
                    placement: "top",
                    $extend: "tooltip",
                    distance: 5,
                    delay: { show: 800, hide: 0 },
                }
            },
        });

and then used like

<span v-tooltip="{ theme: 'info-tooltip', content: 'Some label here' }">

When having hundreds of such tootltips, there is a performance issue when scrolling over the list of 1000 items as the scroll appears to be calling $_computePosition (even if no titles/tooltips are displayed to user) from Popper.ts from this code:

// Scroll
      if (!this.positioningDisabled) {
        addListeners([
          ...getScrollParents(this.$_referenceNode),
          ...getScrollParents(this.$_popperNode),
        ], 'scroll', () => {
          this.$_computePosition()
        })
      }

I guess I understand why it is needed, but would it be possible to either:

  • add ability to skip _computePosition on scroll via props
  • or maybe even better, do not calculate position if tooltip is not displayed?

I've noticed in the $_computePosition there is following condition:

    async $_computePosition () {
      if (this.$_isDisposed || this.positioningDisabled) return

but in my case, the this.$_isDisposed is false so it won't bail out from the method. Not sure if the false is correct or not

@ladariha ladariha changed the title Option to skip position calculation on scroll Skip position calculation on scroll if tooltip is not displayed Mar 10, 2022
@ladariha
Copy link
Author

Here's a reproducible case . You can see the scrolling is laggy but if you uncomment

// positioningDisabled: true,

inside main.js, the performance is much better

@ladariha
Copy link
Author

@Akryum Thanks a lot for quick fix. May I ask if you have some ETA regarding publishing it to NPM registry?

@Akryum
Copy link
Owner

Akryum commented Mar 11, 2022

It is now deployed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants