Installation
Install the component
Run the following command to install the component and its dependencies:
npx @motion-core/cli add infinite-physics-gallerynpx @motion-core/cli add infinite-physics-gallerypnpm dlx @motion-core/cli add infinite-physics-gallerypnpm dlx @motion-core/cli add infinite-physics-gallerybunx @motion-core/cli add infinite-physics-gallerybunx @motion-core/cli add infinite-physics-galleryyarn dlx @motion-core/cli add infinite-physics-galleryyarn dlx @motion-core/cli add infinite-physics-galleryImport the component
Import the component into your Svelte file:
import { InfinitePhysicsGallery } from "motion-core";import { InfinitePhysicsGallery } from "motion-core";Usage
Props
280
360
20
0.950
1.400
120
1.600
<script lang="ts">
import {
InfinitePhysicsGallery,
type InfinitePhysicsGalleryItem,
} from "motion-core";
type Props = {
cellWidth?: number;
cellHeight?: number;
gap?: number;
friction?: number;
wheelSpeed?: number;
edgeThreshold?: number;
edgeScrollSpeed?: number;
};
const items: InfinitePhysicsGalleryItem[] = [
{
id: "img-1",
type: "image",
image: {
src: " /images/photos/sample-image-7.webp",
alt: "Alt 1",
},
},
{
id: "img-2",
type: "image",
image: {
src: " /images/photos/sample-image-8.webp",
alt: "Alt 2",
},
},
{
id: "img-3",
type: "image",
image: {
src: " /images/photos/sample-image-9.webp",
alt: "Alt 3",
},
},
{
id: "img-4",
type: "image",
image: {
src: " /images/photos/sample-image-10.webp",
alt: "Alt 4",
},
},
];
let {
cellWidth = 280,
cellHeight = 360,
gap = 20,
friction = 0.95,
wheelSpeed = 1.4,
edgeThreshold = 120,
edgeScrollSpeed = 1.6,
}: Props = $props();
</script>
<InfinitePhysicsGallery
class="h-full min-h-160 w-full"
{items}
{cellWidth}
{cellHeight}
{gap}
cellClass="rounded-md"
{friction}
scrollSettings={{
wheelSpeed,
friction,
edgeThreshold,
edgeScrollSpeed,
}}
/>
<script lang="ts">
import {
InfinitePhysicsGallery,
type InfinitePhysicsGalleryItem,
} from "motion-core";
type Props = {
cellWidth?: number;
cellHeight?: number;
gap?: number;
friction?: number;
wheelSpeed?: number;
edgeThreshold?: number;
edgeScrollSpeed?: number;
};
const items: InfinitePhysicsGalleryItem[] = [
{
id: "img-1",
type: "image",
image: {
src: " /images/photos/sample-image-7.webp",
alt: "Alt 1",
},
},
{
id: "img-2",
type: "image",
image: {
src: " /images/photos/sample-image-8.webp",
alt: "Alt 2",
},
},
{
id: "img-3",
type: "image",
image: {
src: " /images/photos/sample-image-9.webp",
alt: "Alt 3",
},
},
{
id: "img-4",
type: "image",
image: {
src: " /images/photos/sample-image-10.webp",
alt: "Alt 4",
},
},
];
let {
cellWidth = 280,
cellHeight = 360,
gap = 20,
friction = 0.95,
wheelSpeed = 1.4,
edgeThreshold = 120,
edgeScrollSpeed = 1.6,
}: Props = $props();
</script>
<InfinitePhysicsGallery
class="h-full min-h-160 w-full"
{items}
{cellWidth}
{cellHeight}
{gap}
cellClass="rounded-md"
{friction}
scrollSettings={{
wheelSpeed,
friction,
edgeThreshold,
edgeScrollSpeed,
}}
/>
Props
InfinitePhysicsGallery
| Prop | Type | Default |
|---|---|---|
items | InfinitePhysicsGalleryItem[] | [] |
cellWidth | number | 320 |
cellHeight | number | 400 |
gap | number | 24 |
friction | number | 0.95 |
cellClass | string | "" |
scrollSettings | ScrollSettings | Default Scroll Settings |
class | string | "" |
ScrollSettings
| Key | Type | Default |
|---|---|---|
wheelSpeed | number | 2 |
friction | number | 0.95 |
edgeThreshold | number | 100 |
edgeScrollSpeed | number | 2 |
InfinitePhysicsGalleryItem
| Key | Type | Default |
|---|---|---|
id | stringnumber | undefined |
type | "image""video" | — |
image.src | string | required for image items |
image.alt | string | undefined |
video.src | string | required for video items |