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

useWindowScroll is read only #1978

Closed
7 tasks done
shtse8 opened this issue Jul 22, 2022 · 1 comment · Fixed by #1996
Closed
7 tasks done

useWindowScroll is read only #1978

shtse8 opened this issue Jul 22, 2022 · 1 comment · Fixed by #1996

Comments

@shtse8
Copy link

shtse8 commented Jul 22, 2022

Describe the bug

this reactive function is missing setter.
we can set, but nothing happened.

export function useWindowScroll({ window = defaultWindow }: ConfigurableWindow = {}) {
if (!window) {
return {
x: ref(0),
y: ref(0),
}
}
const x = ref(window.pageXOffset)
const y = ref(window.pageYOffset)
useEventListener(
'scroll',
() => {
x.value = window.pageXOffset
y.value = window.pageYOffset
},
{
capture: false,
passive: true,
},
)
return { x, y }
}

should we watch the ref changed and call window.scrollTo correspondingly?

Reproduction

  1. useWindowScroll

System Info

System:
    OS: Windows 10 10.0.22000ystem --npmPackages '{vue,@vueuse/*}' --binaries --brows
    CPU: (16) x64 Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz
    Memory: 38.44 GB / 63.88 GB
  Binaries:
    Node: 18.6.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.13.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (103.0.1264.62)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    @vueuse/components: ^8.9.4 => 8.9.4
    @vueuse/core: ^8.9.4 => 8.9.4
    @vueuse/motion: ^2.0.0-beta.12 => 2.0.0-beta.12
    @vueuse/nuxt: ^8.9.4 => 8.9.4

Used Package Manager

yarn

Validations

@stale
Copy link

stale bot commented Sep 20, 2022

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 Sep 20, 2022
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.

1 participant