-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Different behavior if arrived directly on page #4048
Comments
Hey, you could use <script>
let animate = false;
afterNavigate(({from}) => !from && (animate = true));
</script> |
I don't think this issue is titled for what you want. Basically using the same idea as above, you can make a module for this to tell if you hit this page directly or if it was navigated to: // src/lib/navigated.js
export let navigated = false;
export const setNavigated = () => { navigated = true }; You've ought to use <!-- src/routes/__layout.svelte -->
<script>
import { afterNavigate } from "$app/navigation";
import { setNavigated } from "$lib/navigated";
afterNavigate(setNavigated);
</script> Because <!-- src/routes/some-page.svelte -->
<script context="module">
import { navigated } from "$lib/navigated";
export const load = async (...) => {
// ... change load behavior based on `navigated`
}
</script>
<!-- ... or do something different in the regular script block or markup --> |
Thank you guys both a lot, that was exactly what I needed 😊 |
Is it possible that Discord threads are not present anymore? Links are going to I understand the idea of Would be nice to have this directly like: |
For organizational purposes: #4447 is a future issue that's still open about the same topic |
Describe the problem
I'm currently trying to play an intro animation when the index route is hit directly. This animation should not play when the user navigated to to the index route from another route. In classical websites i would have looked at the http referer and checked if its empty or has an external domain but in sveltekit inthe page store there is no such equivalent.
Describe the proposed solution
add a referer string to the page store which works like the http referer
Alternatives considered
I tried creating a custom store which derives from the page store but since I'm new to svelte and sveltekit I could not get that going really.
Importance
would make my life easier
Additional Information
No response
The text was updated successfully, but these errors were encountered: