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

useScroll: cannot pass window to "getComputedStyle" as an element #3136

Closed
7 tasks done
mu16zi opened this issue Jun 3, 2023 · 7 comments · Fixed by #3280
Closed
7 tasks done

useScroll: cannot pass window to "getComputedStyle" as an element #3136

mu16zi opened this issue Jun 3, 2023 · 7 comments · Fixed by #3280

Comments

@mu16zi
Copy link

mu16zi commented Jun 3, 2023

Describe the bug

when I try to pass window to useInfiniteScroll as the element to track scroll on it, this issue occurs.

the error:

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'

I checked the source of error found that since the useInfiintieScroll passes the element to useScroll and the useScroll passes the element to getComputedStyle to get the desired element data, the error is occurs.
The getComputedStyle calls inside the setArrivedState function in the useScroll.

Reproduction

System Info

-

Used Package Manager

npm

Validations

@stale
Copy link

stale bot commented Aug 21, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 21, 2023
@steklopod
Copy link
Contributor

I have the same error after nuxt ipgrade to 3.8.1:

const scrollBox = ref<HTMLDivElement>()

const { arrivedState } = useScroll(scrollBox) // <-- 👈🏻 This gives an error now

Before update everything was working
Снимок экрана 2023-11-16 в 16 06 03

Снимок экрана 2023-11-16 в 16 06 23

@wangliangxin
Copy link
Contributor

I have the same error after nuxt ipgrade to 3.8.1:

const scrollBox = ref<HTMLDivElement>()

const { arrivedState } = useScroll(scrollBox) // <-- 👈🏻 This gives an error now

Before update everything was working Снимок экрана 2023-11-16 в 16 06 03

Снимок экрана 2023-11-16 в 16 06 23

"I also encountered the same problem. How did you solve it?"

@mu16zi
Copy link
Author

mu16zi commented Jan 26, 2024

I have the same error after nuxt ipgrade to 3.8.1:

const scrollBox = ref<HTMLDivElement>()

const { arrivedState } = useScroll(scrollBox) // <-- 👈🏻 This gives an error now

Before update everything was working Снимок экрана 2023-11-16 в 16 06 03
Снимок экрана 2023-11-16 в 16 06 23

"I also encountered the same problem. How did you solve it?"

If I'm not mistaken, I remember that I used document instead of window object as the element and that worked for my case,
but I though this issue was fixed after the pull request merged and I didn't test it after that.
upgrade your vueuse pkg and then check if the problem is fixed or not, Or Try to use document instead of window if you want to track scroll on it.

@steklopod
Copy link
Contributor

steklopod commented Jan 26, 2024

I have the same error after nuxt ipgrade to 3.8.1:

const scrollBox = ref<HTMLDivElement>()

const { arrivedState } = useScroll(scrollBox) // <-- 👈🏻 This gives an error now

Before update everything was working Снимок экрана 2023-11-16 в 16 06 03
Снимок экрана 2023-11-16 в 16 06 23

"I also encountered the same problem. How did you solve it?"

It's not solved yet because MR is not merged. Maybe let's ask @antfu to re-review: #3605

@steklopod
Copy link
Contributor

I have the same error after nuxt ipgrade to 3.8.1:

const scrollBox = ref<HTMLDivElement>()

const { arrivedState } = useScroll(scrollBox) // <-- 👈🏻 This gives an error now

Before update everything was working Снимок экрана 2023-11-16 в 16 06 03
Снимок экрана 2023-11-16 в 16 06 23

"I also encountered the same problem. How did you solve it?"

If I'm not mistaken, I remember that I used document instead of window object as the element and that worked for my case, but I though this issue was fixed after the pull request merged and I didn't test it after that. upgrade your vueuse pkg and then check if the problem is fixed or not, Or Try to use document instead of window if you want to track scroll on it.

The Scroll is on an HtmlElement. Not on window/document.

@Blackfaded
Copy link
Contributor

Facing the same issue on a component which is a componentinstance. Would love to see the above PR merged

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

Successfully merging a pull request may close this issue.

4 participants