Not sure if svelte-routing works on cordova
It does work.
How do you page transition/animation using svelte-routing?
You just add your transitions to your dom elements as you normaly do.
Transitions in svelte trigger when components are mounted and destroyed, and svelte-routing manages mounting and destroying components for you.
Remember that transitions don’t work on components because in Svelte there’s no guarantee that a component has only one single wrapper like in Vue or React, so you have to add your wrapper manually (a dom element as a wrapper to be more precise).
Here’s an example:
This is the entry file (App.svelte)
<script>
import HomePage from './pages/HomePage.svelte';
import { Router, Route } from 'svelte-routing';
import { App, View } from 'framework7-svelte';
import AboutPage from './pages/AboutPage.svelte';
import { scale } from 'svelte/transition';
let url = window.location.pathname;
</script>
<App>
<View main>
<Router url="{url}">
<Route path="/about/:someParameter" let:params>
<div transition:scale={{duration:200}}>
<AboutPage {...params}/>
</div>
</Route>
<Route path="/**">
<div transition:scale={{duration:200}}>
<HomePage/>
</div>
</Route>
</Router>
</View>
</App>
<style>
/* Custom color theme properties */
:global(:root) {
--f7-theme-color: #F17010;
--f7-theme-color-rgb: #ffffff;
--f7-theme-color-shade: #cc5e0c;
--f7-theme-color-tint: #f38737;
}
</style>
this is the home page
<script>
import {
Page,
Navbar,
NavTitle,
NavRight,
Link,
Block,
Button
} from 'framework7-svelte';
import { navigate } from 'svelte-routing';
</script>
<Page>
<Navbar>
<NavTitle>Home Page</NavTitle>
<NavRight>
<Link iconIos="f7:search" iconAurora="f7:search" iconMd="material:search"></Link>
</NavRight>
</Navbar>
<br />
<br />
<Block class="p-0">
<div class="grid-x-center">
This is the home page <br />
<Button onClick={()=>navigate("/about/hello-world")}>go to about page</Button>
</div>
</Block>
</Page>
and this is the about page
<script>
import {
Page,
Navbar,
NavTitle,
NavRight,
Link,
Block,
Button
} from 'framework7-svelte';
import { navigate } from 'svelte-routing';
export let someParameter;
</script>
<Page>
<Navbar>
<NavTitle>About Page</NavTitle>
<NavRight>
<Link iconIos="f7:search" iconAurora="f7:search" iconMd="material:search"></Link>
</NavRight>
</Navbar>
<br />
<br />
<Block class="p-0">
<div class="grid-x-center">
This is the about page, and this is a parmeter: {someParameter} <br />
<Button onClick={()=>navigate("/")}>go to home page</Button>
</div>
</Block>
</Page>
Here’s what the url looks like when you debug it:

NOTE: if you want your animations to be smooth and not stack on eachother, always use some sort of element/component that covers the whole view, like framework7’s <View></View>
component, this will make it so that the stack happens offscreen.