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

useElementVisibility not working anymore after upgrade #2970

Closed
7 tasks done
francoism90 opened this issue Apr 14, 2023 · 5 comments
Closed
7 tasks done

useElementVisibility not working anymore after upgrade #2970

francoism90 opened this issue Apr 14, 2023 · 5 comments

Comments

@francoism90
Copy link
Contributor

Describe the bug

First, congrats on releasing v10.0.0! :)

One of the issues I'm having after is upgrading, is useElementVisibility stops working. It always hides the element, even when it's in the viewport.
I'm using this inside a PostItem.vue component on an overview page with infinite scroll:

<template>
  <div ref="element" class="min-h-16 h-16">
    <template v-if="visible">
      <div class="card">card</div>
    </template>
  </div>
</template>

<script setup lang="ts">
import { useElementVisibility } from "@vueuse/core";

const element = ref<HTMLElement | undefined>();

const visible = useElementVisibility(element);
</script>

It's hard to provide a reproduction link, as it could have something to do with my code. Maybe you also provide a better solution for this, as Quasar provided an observer that does this on the fly.

Thanks!

Reproduction

https://stackblitz.com/edit/vitejs-vite-rptfks

System Info

System:
    OS: Linux 6.2 Fedora Linux 37
    CPU: N/A
    Memory: N/A
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.15.0 - /usr/bin/node
    npm: 9.5.0 - /usr/bin/npm
  npmPackages:
    @vueuse/components: ^10.0.0 => 10.0.0 
    @vueuse/core: ^10.0.0 => 10.0.0 
    @vueuse/head: ^1.1.23 => 1.1.23 
    @vueuse/math: ^10.0.0 => 10.0.0 
    vue: ^3.2.47 => 3.2.47

Used Package Manager

npm

Validations

@antfu
Copy link
Member

antfu commented Apr 14, 2023

Your reproduction is empty

@schelmo
Copy link
Contributor

schelmo commented Apr 14, 2023

this was fixed by #2968

@cuebit
Copy link

cuebit commented Apr 14, 2023

useElementVisibility now uses useIntersectionObserver which broke in v10 and is resolved by #2968 – you'll want to wait for a patch release.

@antfu
Copy link
Member

antfu commented Apr 14, 2023

Patch released. Thanks

@antfu antfu closed this as completed Apr 14, 2023
@francoism90
Copy link
Contributor Author

francoism90 commented Apr 14, 2023

@antfu Sorry for posting an empty example! I've pasted the wrong URL. :/
Thanks for the quick fix! :)

Edit: just to confirm, it indeed fixed the issue.

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

No branches or pull requests

4 participants