Skip to content

Commit

Permalink
Update sveltegram example
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloricciuti committed Sep 28, 2023
1 parent d03517f commit 26e29c3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/sveltegram/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"prettier-plugin-svelte": "^3.0.3",
"svelte": "^4.0.5",
"svelte-check": "^3.4.3",
"sveltekit-view-transition": "^0.3.1",
"sveltekit-view-transition": "^0.5.0",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^4.4.2"
Expand Down
8 changes: 4 additions & 4 deletions examples/sveltegram/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions examples/sveltegram/src/lib/Post.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import type { Photo, User } from '$lib/fake-data';
import type { OnNavigate } from '@sveltejs/kit';
import { setupViewTransition } from 'sveltekit-view-transition';
import type { TransitionActionFunctions } from 'sveltekit-view-transition';
const { transition } = setupViewTransition();
Expand All @@ -13,12 +14,15 @@
export let user: User;
type $$Props = Photo;
function shouldApply({ navigation }: { navigation: OnNavigate }) {
const shouldApply: TransitionActionFunctions['shouldApply'] = ({ navigation }) => {
return navigation.to?.params?.id === id.toString();
}
function applyImmediately({ navigation }: { navigation: OnNavigate }) {
return navigation.from?.params?.id === id.toString();
}
};
const applyImmediately: TransitionActionFunctions['applyImmediately'] = ({
navigation,
isInViewport
}) => {
return isInViewport && navigation.from?.params?.id === id.toString();
};
$: comments_num = comments.filter((comment) => comment.photo_id === id).length;
$: comments_sentence = `comment${comments_num !== 1 ? 's' : ''}`;
Expand Down

1 comment on commit 26e29c3

@vercel
Copy link

@vercel vercel bot commented on 26e29c3 Sep 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.