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

TypeError: Cannot read property '_infiniteScrollHeight' of null #254

Open
kvanska opened this issue Jun 27, 2019 · 11 comments
Open

TypeError: Cannot read property '_infiniteScrollHeight' of null #254

kvanska opened this issue Jun 27, 2019 · 11 comments

Comments

@kvanska
Copy link

kvanska commented Jun 27, 2019

2.4.4

Vue.js version 2.6.10

Nuxt.js version 2.8

Steps to reproduce

When loading page without infinite-loading control and then navigatin to another page (SPA) that has infinite-loading, getting exception "TypeError: Cannot read property '_infiniteScrollHeight' of null"

What is Expected?

no exception

What is actually happening?

getScrollParent function recursively finds the parent element and for some reason when loading in SPA, parent node is null for:

on page refresh it's not null and parent is set to window

here it's said that

".... if all failed, the component will use window as the scroll container."

In this case it clearly fails but window is not set as the scroll container.

kvanska added a commit to kvanska/vue-infinite-loading that referenced this issue Jun 27, 2019
@kvanska kvanska mentioned this issue Jun 27, 2019
edwh added a commit to Freegle/iznik-nuxt that referenced this issue Jan 17, 2020
…chScript/vue-infinite-loading#254 .  Done this by patch-package, because I'm failing to make this build from master (which includes the fix) rather than the released version.
@edwh
Copy link

edwh commented Jan 17, 2020

I hit this problem - thanks for the fix. Any chance of doing a release soon that includes this?

@Frozire
Copy link

Frozire commented Jan 22, 2020

I hit this problem too, @PeachScript - anything we can do to help push this change?

@nicolashmln
Copy link

Same problem here

@jawn-ha
Copy link

jawn-ha commented Mar 31, 2020

same problem

@jankaderabek
Copy link

Hi, I have the same problem. Is there any chance that #255 will be merged soon?

@DomcaSuzi
Copy link

I needed this fix too. For the time being I was using kuroskis forked repository with fix, but he deleted it. I created new forked repo with this fix #255
Feel free to rewrite your package.json dependencies to "vue-infinite-loading": "https://github.com/DomcaSuzi/vue-infinite-loading".

@phyzerbert
Copy link

I hit this problem - thanks for the fix. Any chance of doing a release soon that includes this?

Too many requests for this props force-use-infinite-wrapper="body"

@andreasvirkus
Copy link

@phyzerbert thanks! this solved it for me 🎉

@iulo
Copy link

iulo commented May 19, 2021

@andreasvirkus What do you mean this solved it for me ?
you shouldn't use force-use-infinite-wrapper="body", it is the wrong way.

@andreasvirkus
Copy link

@iulo why is it the wrong way? It didn't degrade performance, didn't cause any extra bugs and solved the annoying errors. Checked all my boxes 🤷‍♀️ 🙊

@iulo
Copy link

iulo commented May 26, 2021

@andreasvirkus when you set force-use-infinite-wrapper="body", ths scrollParent will set to body element, not the window.

if (typeof this.forceUseInfiniteWrapper === 'string') {
result = document.querySelector(this.forceUseInfiniteWrapper);
}
if (!result) {
if (elm.tagName === 'BODY') {
result = window;

then getCurrentDistance will always return a number <=0

getCurrentDistance() {
let distance;
if (this.direction === 'top') {
distance = typeof this.scrollParent.scrollTop === 'number'
? this.scrollParent.scrollTop
: this.scrollParent.pageYOffset;
} else {
const infiniteElmOffsetTopFromBottom = this.$el.getBoundingClientRect().top;
const scrollElmOffsetTopFromBottom = this.scrollParent === window
? window.innerHeight
: this.scrollParent.getBoundingClientRect().bottom;
distance = infiniteElmOffsetTopFromBottom - scrollElmOffsetTopFromBottom;
}

so the loading behavior will be triggered all the time until it is completed which I think it's not what you expected.

Try the demo below to see what happens.
https://codepen.io/iulo/pen/xxqrzrZ

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

10 participants