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

Not working with v-show #17

Open
pscs opened this issue Dec 13, 2019 · 2 comments
Open

Not working with v-show #17

pscs opened this issue Dec 13, 2019 · 2 comments

Comments

@pscs
Copy link

pscs commented Dec 13, 2019

I couldn't get this to work if the component is being displayed using v-show.

After much debugging I found that the 'visibility listener' wasn't triggering when the component became visible.

After much more debugging (I didn't know how IntersectionObserver worked) I found that it appears that the 'root' option was causing the problem. The code has it set to 'document.documentElement', which you'd have thought would work, but actually seemed to be showing as an element of 0x0 pixels. Removing the 'root' option so that it became the default of the viewport made everything work correctly.

ie - changing

function listenToVisible(element, callback) {
const options = {
root: document.documentElement
};
.....

to

function listenToVisible(element, callback) {
const options = {
};
....

seems to have fixed the problem for me.

@pscs
Copy link
Author

pscs commented Dec 13, 2019

More Info - this is in Chrome v78

Changing root to "document.body" still doesn't fix the problem (again, the Observer's "root bounds" seem to be a 0x0 pixel area)

But changing it to "document.getElementById('App')" with the default Vue.js app template works (the root bounds are correctly set and it detects the component becoming visible)

@Ilya1vanov
Copy link

Same here

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

2 participants