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

window.scrollY always is 0 #226

Open
6 tasks done
betim opened this issue Dec 18, 2024 · 1 comment
Open
6 tasks done

window.scrollY always is 0 #226

betim opened this issue Dec 18, 2024 · 1 comment
Labels
Svelte Issue with Tailwind Mobile Svelte

Comments

@betim
Copy link

betim commented Dec 18, 2024

Check that this is really a bug

  • I confirm

Reproduction link

n/a

Bug description

Hi,

No matter what I do, I can't seem to get window.scrollY to work, nor the window.scrollTo works.

For example:

<script>
  import { Page } from "konsta/svelte";

  import Header from "./Header.svelte";
  import Footer from "./Footer.svelte";
  import { onDestroy } from "svelte";

  onDestroy(() => {
    console.log(window.scrollY);
  });
</script>

<Page>
  <Header />
  <slot />
  <Footer />
</Page>

Always logs 0.

Any ideas as to why is this happening?

Expected Behavior

The actual value of where the page is scrolled.

Actual Behavior

0

Konsta UI version

^4.0.1

Platform/Target and Browser Versions

Chromium

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a Konsta UI issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR
@betim betim added the Svelte Issue with Tailwind Mobile Svelte label Dec 18, 2024
@betim
Copy link
Author

betim commented Dec 19, 2024

To clarify a bit more, I'm using svelte-spa-router which internally uses window.scrollY to store the position of a previous page and when the user presses the back button it scrolls to that position. window.scrollY is 0 in this case.

I tried to google for a solution but could not find any hints as to why this might happen. One guy said that overflow: auto is the culprit, I tried to work around that but again, both browsers' window.scrollY reported 0.

Please advice.

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

No branches or pull requests

1 participant