Skip to content

Commit abb8854

Browse files
committed
refactor: improve marquee
1 parent cf5c238 commit abb8854

File tree

29 files changed

+597
-295
lines changed

29 files changed

+597
-295
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@zag-js/marquee": patch
3+
---
4+
5+
- Fix Firefox flicker when marquee animation loops
6+
- Use margin-based spacing instead of gap for items
7+
- Use `backface-visibility: hidden` for better GPU acceleration
8+
- Add new `item` part with `getItemProps()` method

examples/next-ts/pages/marquee.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function Page() {
2727
{Array.from({ length: api.contentCount }).map((_, index) => (
2828
<div key={index} {...api.getContentProps({ index })}>
2929
{marqueeData.map((item, i) => (
30-
<div key={i} className="marquee-item">
30+
<div key={i} {...api.getItemProps()}>
3131
<span className="marquee-logo">{item.logo}</span>
3232
<span className="marquee-name">{item.name}</span>
3333
</div>

examples/nuxt-ts/pages/marquee.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const api = computed(() => marquee.connect(service, normalizeProps))
2424

2525
<div v-bind="api.getViewportProps()">
2626
<div v-for="index in api.contentCount" :key="index - 1" v-bind="api.getContentProps({ index: index - 1 })">
27-
<div v-for="(item, i) in marqueeData" :key="i" class="marquee-item">
27+
<div v-for="(item, i) in marqueeData" :key="i" v-bind="api.getItemProps()">
2828
<span class="marquee-logo">{{ item.logo }}</span>
2929
<span class="marquee-name">{{ item.name }}</span>
3030
</div>

examples/solid-ts/src/routes/marquee.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function Page() {
3131
<div {...api().getContentProps({ index })}>
3232
<For each={marqueeData}>
3333
{(item) => (
34-
<div class="marquee-item">
34+
<div {...api().getItemProps()}>
3535
<span class="marquee-logo">{item.logo}</span>
3636
<span class="marquee-name">{item.name}</span>
3737
</div>

examples/svelte-ts/src/routes/marquee/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
{#each Array.from({ length: api.contentCount }) as _, index}
2929
<div {...api.getContentProps({ index })}>
3030
{#each marqueeData as item}
31-
<div class="marquee-item">
31+
<div {...api.getItemProps()}>
3232
<span class="marquee-logo">{item.logo}</span>
3333
<span class="marquee-name">{item.name}</span>
3434
</div>

packages/docs/data/api.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,14 +2342,58 @@
23422342
},
23432343
"image-cropper": {
23442344
"api": {
2345+
"zoom": {
2346+
"type": "number",
2347+
"description": "The current zoom level of the image."
2348+
},
2349+
"rotation": {
2350+
"type": "number",
2351+
"description": "The current rotation of the image in degrees."
2352+
},
2353+
"flip": {
2354+
"type": "FlipState",
2355+
"description": "The current flip state of the image."
2356+
},
2357+
"crop": {
2358+
"type": "Rect",
2359+
"description": "The current crop area rectangle in viewport coordinates."
2360+
},
2361+
"offset": {
2362+
"type": "Point",
2363+
"description": "The current offset (pan position) of the image."
2364+
},
2365+
"naturalSize": {
2366+
"type": "Size",
2367+
"description": "The natural (original) size of the image."
2368+
},
2369+
"viewportRect": {
2370+
"type": "BoundingRect",
2371+
"description": "The viewport rectangle dimensions and position."
2372+
},
2373+
"dragging": {
2374+
"type": "boolean",
2375+
"description": "Whether the crop area is currently being dragged."
2376+
},
2377+
"panning": {
2378+
"type": "boolean",
2379+
"description": "Whether the image is currently being panned."
2380+
},
23452381
"setZoom": {
23462382
"type": "(zoom: number) => void",
23472383
"description": "Function to set the zoom level of the image."
23482384
},
2385+
"zoomBy": {
2386+
"type": "(delta: number) => void",
2387+
"description": "Function to zoom the image by a relative amount."
2388+
},
23492389
"setRotation": {
23502390
"type": "(rotation: number) => void",
23512391
"description": "Function to set the rotation of the image."
23522392
},
2393+
"rotateBy": {
2394+
"type": "(degrees: number) => void",
2395+
"description": "Function to rotate the image by a relative amount in degrees."
2396+
},
23532397
"setFlip": {
23542398
"type": "(flip: Partial<FlipState>) => void",
23552399
"description": "Function to set the flip state of the image."
@@ -2366,9 +2410,17 @@
23662410
"type": "(handlePosition: HandlePosition, delta: number) => void",
23672411
"description": "Function to resize the crop area from a handle programmatically."
23682412
},
2413+
"reset": {
2414+
"type": "() => void",
2415+
"description": "Function to reset the cropper to its initial state."
2416+
},
23692417
"getCroppedImage": {
23702418
"type": "(options?: GetCroppedImageOptions) => Promise<string | Blob>",
23712419
"description": "Function to get the cropped image with all transformations applied.\nReturns a Promise that resolves to either a Blob or data URL."
2420+
},
2421+
"getCropData": {
2422+
"type": "() => CropData",
2423+
"description": "Function to get the crop data in natural image pixel coordinates.\nThese coordinates are relative to the original image dimensions,\naccounting for zoom, rotation, and flip transformations.\nUse this for server-side cropping or state persistence."
23722424
}
23732425
},
23742426
"context": {

0 commit comments

Comments
 (0)