कैरसेल
दृश्य आइटम की एक पंक्ति, जो एक मुख्य आइटम के इर्द-गिर्द आड़ी स्क्रॉल होती है और जिसका हर आइटम वह चीज़ खोलता है जो वह दिखाता है। फ़ीचर्ड पंक्ति लूप कर सकती है, बिंदुओं से अपनी जगह दिखा सकती है और अपने आप आगे बढ़ सकती है।
- श्रेणी
- कंटेनमेंट
- टोकन
comp.carousel- स्तर
- आधार
- Web
tanrei-carouselschedule - SwiftUI
TanreiCarouselschedule - Jetpack Compose
TanreiCarouselschedule - Flutter
TanreiCarouselschedule - React Native
Carouselschedule
इससे जनरेट किया गया: docs/status/status.json, specs/carousel.spec.json
संशोधित स्पेक, जो अभी हर प्लैटफ़ॉर्म पर नहीं है
यह पेज कैरसेल को वैसा बताता है जैसा स्पेक में वह अभी है। layout प्रॉपर्टी की जगह अब स्वतंत्र चुनाव हैं (हीरो कहाँ रहता है, फ़्लुइड या तय चौड़ाइयाँ, स्केल, स्नैप, लूप), और फ़ीचर्ड पंक्ति बिंदु दिखा सकती है और अपने आप आगे बढ़ सकती है। हीरो अब डिफ़ॉल्ट रूप से बीच में रहता है, और पड़ोसी आइटम स्क्रॉल की हर स्थिति में एक-दूसरे से एक गैप की दूरी पर रहते हैं। वेब कंपोनेंट यह सब पहले से करता है, और डेमो भी। SwiftUI, Compose, Flutter और React Native ऊपर “पीछे” के रूप में चिह्नित हैं: जब तक वे बराबरी पर नहीं आते, वे पिछला संशोधन देते हैं, जिसमें layout है और लूप, बिंदु, ऑटोप्ले या पिछला और अगला कंट्रोल नहीं हैं। हीरो डिफ़ॉल्ट रूप से बीच में होता है और layout से आगे बढ़ना देखें।
डिफ़ॉल्ट: हीरो बीच में, उसके बग़ल में एक छोटा आइटम
कैरसेल में एक ही तरह का आइटम होता है, item। हर प्लैटफ़ॉर्म आइटम उसी तरह लेता है जैसे वह दोहराए जाने वाले किसी भी चाइल्ड को लेता है: वेब पर <tanrei-carousel-item> चाइल्ड, SwiftUI पर व्यू बिल्डर में TanreiCarouselItem व्यू, Compose पर आइटम लैम्ब्डा से TanreiCarouselItem के कॉल, Flutter पर children में TanreiCarouselItem विजेट, और React Native पर CarouselItem चाइल्ड।
हर आइटम एक क्रिया है। उसमें आपका कॉन्टेंट रहता है, आम तौर पर एक इमेज, और जब व्यक्ति उसे सक्रिय करता है तो वह click एमिट करता है (प्लैटफ़ॉर्म के अनुसार action, onClick, onTap या onPress)। उसका label उसका एक्सेसिबल नाम है: बताएँ कि कॉन्टेंट क्या दिखाता है, जैसे “तटीय पगडंडी, 12 फ़ोटो”। कॉन्टेंट ख़ुद सहायक तकनीक से छिपा रहता है, और उसमें अपना कोई कंट्रोल नहीं होना चाहिए।
पंक्ति एक मुख्य आइटम के इर्द-गिर्द सजती है, जिसे हीरो कहते हैं। कैसे, यह कुछ स्वतंत्र प्रॉपर्टी बताती हैं, और हर एक का डिफ़ॉल्ट ऐसी पंक्ति के अनुकूल है जिसे ब्राउज़ किया जाता है: हीरो बीच में, उसके बग़ल के आइटम सँकरे, और ऐसी पंक्ति जो पूरे आइटम पर ठहरती है। itemWidth हीरो की चौड़ाई है; डिज़ाइन सिस्टम का डिफ़ॉल्ट लेने के लिए इसे सेट न करें। फ़ीचर्ड पंक्ति में loop, बिंदु (indicator) और autoplay जोड़े जा सकते हैं। autoplay के बिना कैरसेल का कोई मान नहीं होता जिसे कंट्रोल किया जाए: वह तब स्क्रॉल होता है जब व्यक्ति उसे स्क्रॉल करता है या फ़ोकस ले जाता है।
पंक्ति के दोनों सिरों के ऊपर एक पिछला और एक अगला कंट्रोल उसे एक-एक आइटम आगे-पीछे करते हैं। डिफ़ॉल्ट रूप से वे माउस या ट्रैकपैड के लिए बनते हैं, और तब दिखते हैं जब पॉइंटर कैरसेल के ऊपर हो या फ़ोकस उसके भीतर हो। उन्हें अपने प्रॉडक्ट की भाषा में previousLabel और nextLabel दें। पिछला और अगला कंट्रोल देखें।
Web और React के उदाहरण मौजूदा स्पेक दिखाते हैं। SwiftUI, Compose, Flutter और React Native के उदाहरण पिछला संशोधन दिखाते हैं, जो वे प्लैटफ़ॉर्म आज देते हैं: layout (डिफ़ॉल्ट रूप से एक पंक्ति में कई आइटम, hero या uncontained) और itemWidth, बिना लूप, बिंदु या ऑटोप्ले के।
<tanrei-carousel previous-label="पिछली सैर" next-label="अगली सैर" label="आपके पास की सैर">
<tanrei-carousel-item label="तटीय पगडंडी, 12 फ़ोटो"><img src="coast.jpg" alt="" /></tanrei-carousel-item>
<tanrei-carousel-item label="पुराना शहर, 8 फ़ोटो"><img src="town.jpg" alt="" /></tanrei-carousel-item>
<tanrei-carousel-item label="जंगल का चक्कर, 20 फ़ोटो"><img src="forest.jpg" alt="" /></tanrei-carousel-item>
</tanrei-carousel>
<!-- फ़ीचर्ड पंक्ति: अंतहीन, बिंदुओं के साथ, अपने आप आगे बढ़ती हुई। हीरो डिफ़ॉल्ट रूप से बीच में होता है। -->
<tanrei-carousel previous-label="पिछली सैर" next-label="अगली सैर" label="चुनिंदा सैर" loop indicator autoplay
play-label="स्लाइड शो चलाएँ" pause-label="स्लाइड शो रोकें">…</tanrei-carousel>
<!-- शुरुआती किनारे से चलने वाली सादी पंक्ति: हर आइटम 120 चौड़ा (CSS पिक्सल की संख्या), और स्क्रॉल जहाँ
ख़त्म हो वहीं ठहरती है। fixed-width और free-scroll, fluidWidth और snap के उलटे हैं, जिनका डिफ़ॉल्ट true है। -->
<tanrei-carousel previous-label="पिछली सैर" next-label="अगली सैर" label="हाल में देखे गए" hero-alignment="start" fixed-width free-scroll item-width="120">…</tanrei-carousel>
<script type="module">
import '@tanrei/web/components/carousel';
for (const item of document.querySelectorAll('tanrei-carousel-item')) {
item.addEventListener('click', () => openWalk(item.label));
}
// इसे सिर्फ़ प्लेबैक कंट्रोल एमिट करता है, ठहराव नहीं, और तब भी नहीं जब आप paused सेट करते हैं।
document.querySelector('[label="चुनिंदा सैर"]').addEventListener('pausedchange', (e) => savePaused(e.detail.paused));
</script>import { Carousel, CarouselItem } from '@tanrei/react';
<Carousel label="हाल में देखे गए" itemWidth={120} fluidWidth={false} snap={false}>
{walks.map((walk) => (
<CarouselItem key={walk.id} label={walk.label} onClick={() => openWalk(walk)}>
<img src={walk.image} alt="" />
</CarouselItem>
))}
</Carousel>
<Carousel label="चुनिंदा सैर" loop indicator autoplay paused={paused}
onPausedChange={(e) => setPaused(e.detail.paused)}
previousLabel="पिछली सैर" nextLabel="अगली सैर"
playLabel="स्लाइड शो चलाएँ" pauseLabel="स्लाइड शो रोकें">
{featured.map((walk) => <CarouselItem key={walk.id} label={walk.label} onClick={() => openWalk(walk)}><img src={walk.image} alt="" /></CarouselItem>)}
</Carousel>import Tanrei
// पिछला संशोधन: layout तय करता है कि पंक्ति कैसे सजे। .hero एक बार में एक फ़ीचर्ड आइटम है।
TanreiCarousel("चुनिंदा सैर", layout: .hero) {
ForEach(walks) { walk in
TanreiCarouselItem(walk.label, action: { open(walk) }) {
WalkImage(walk)
}
}
}import androidx.compose.ui.unit.dp
import io.github.chnotchy.tanrei.components.TanreiCarousel
import io.github.chnotchy.tanrei.components.TanreiCarouselItem
import io.github.chnotchy.tanrei.components.TanreiCarouselLayout
// पिछला संशोधन। एक आइटम लैम्ब्डा, जैसा Material के कैरसेल लेते हैं। itemWidth एक Dp है, या टोकन के लिए null।
// Uncontained एक सादी पंक्ति है: हर आइटम बराबर चौड़ा, किनारे पर कटा हुआ।
TanreiCarousel(
itemCount = walks.size,
contentDescription = "हाल में देखे गए",
layout = TanreiCarouselLayout.Uncontained,
itemWidth = 120.dp,
) { index ->
val walk = walks[index]
TanreiCarouselItem(label = walk.label, onClick = { open(walk) }) {
WalkImage(walk)
}
}import 'package:tanrei/tanrei.dart';
// पिछला संशोधन: layout तय करता है कि पंक्ति कैसे सजे।
TanreiCarousel(
semanticLabel: 'चुनिंदा सैर',
layout: TanreiCarouselLayout.hero,
children: [
for (final Walk walk in walks)
TanreiCarouselItem(label: walk.label, onTap: () => open(walk), child: WalkImage(walk)),
],
),import { Image } from 'react-native';
import { Carousel, CarouselItem } from '@tanrei/react-native';
// पिछले संशोधन का डिफ़ॉल्ट लेआउट: एक पंक्ति में कई आइटम।
<Carousel accessibilityLabel="आपके पास की सैर">
{walks.map((walk) => (
<CarouselItem key={walk.id} label={walk.label} onPress={() => openWalk(walk)}>
<Image source={walk.image} style={{ flex: 1 }} />
</CarouselItem>
))}
</Carousel>जितना हो सके उतना चौड़ा हीरो, और तय चौड़ाइयाँ जो शुरुआती किनारे से खुलकर स्क्रॉल होती हैं
पंक्ति को सजाना: तय चौड़ाइयाँ, स्केल, लूप, हीरो की ओर का कॉन्टेंट
fixed-width free-scrollfixed-width scale-others looploopitem-width=“120” content-alignment=“toward-hero” loopबिंदु, ऑटोप्ले, प्रगति, रुका हुआ, और अकेला प्लेबैक कंट्रोल
indicatorindicator autoplayautoplay-progresspausedजहाँ “मोशन कम करें” सेटिंग चालू है, वहाँ ऑटोप्ले कभी नहीं चलता: वहाँ ऑटोप्ले के डेमो स्थिर रहते हैं, और उनमें प्लेबैक कंट्रोल और प्रगति नहीं होते।
संरचना
| भाग | विवरण |
|---|---|
1 row | The row of items: as wide as the carousel, scrolling sideways, padded at its start and end. Items scroll under the padding to its edges, every two neighbours the same gap apart. |
2 item | One item of the row (an item of the item kind). The item in focus is the hero, in the middle of the row unless heroAlignment puts it at the start; with fluid widths the others narrow as they move away from it, and with scaleOthers they are drawn smaller. |
3 item.container | The item's rounded box. It clips the item's content, fills what the content leaves uncovered, and carries hover, focus and press. |
4 item.content | What the product puts in the item (an image, a poster). The carousel lays it out at the hero's width and aligns it in the container (centred, or toward the hero), so a narrower item shows part of it. |
5 focus-ring · वैकल्पिक | Gap-then-ring indicator for keyboard focus: inside an item's container, which the row would otherwise clip, and around the indicator's or the playback control's container. |
6 previous · वैकल्पिक | The previous control: an icon-only Button over the row's inline start, centred on the row's height, that moves the row back by one resting position. Drawn as navigation says, while there are at least two resting positions (CRL-41). |
7 next · वैकल्पिक | The next control: an icon-only Button over the row's inline end, centred on the row's height, that moves the row on by one resting position. Drawn as navigation says, while there are at least two resting positions (CRL-41). |
8 controls · वैकल्पिक | The controls row directly below the items, drawn while the indicator or the playback control is. It does not scroll. |
9 indicator · वैकल्पिक | The dots, centred in the controls row: one per resting position, the current one stretched, the stretch following the scroll. One control (a slider) whose container carries hover, focus and press. |
10 indicator.dot | One dot: a pill of the dot size, stretched toward the active width as the row nears its position; the current dot may fill to show the time until autoplay moves on. |
11 playback · वैकल्पिक | The playback control at the end of the controls row, drawn while autoplay is on: an icon-only button, a circle, that pauses and plays. |
12 playback.icon | The glyph of the icon set: `pause` while autoplay is playing, `play_arrow` while it is paused. Never mirrored. |
प्रॉपर्टी
| प्रॉपर्टी | टाइप | डिफ़ॉल्ट | विवरण |
|---|---|---|---|
heroAlignment | start | center | "center" | Where the item in focus (the hero) sits: in the middle, with items on both sides (the default), or at the inner start edge (the left in a left-to-right language), with items after it only. Not a token axis: geometry, read from the same tokens. |
itemWidth | number | null | The width the hero is laid out at, in the platform's unit (CSS px, pt, dp, logical pixels); null takes comp.carousel.container.large-width. With fixed widths every item is this wide (at most the inner width); with fluid widths the hero is kept between a floor and a cap that leave room for the others (CRL-9). Choose it from the content's shape: a product's posters and thumbnails differ. |
fluidWidth | boolean | true | Whether item widths change fluidly: true narrows the items beside the hero (on both sides of a hero in the centre) to a medium and a small width, each width following the scroll; false makes every item the hero's width, the ones that do not fit cut by the carousel's edges. |
contentAlignment | center | toward-hero | "center" | With fluid widths, where a narrowed item's content is anchored: center shows its middle; toward-hero aligns the items after the hero to their start and the items before it to their end, so each shows the side nearest the hero. Ignored while fluidWidth is false. |
scaleOthers | boolean | false | Whether the items other than the hero are drawn smaller, down to comp.carousel.container.min-scale, the scale following the scroll and the gap between drawn items staying the same. It applies with fluid or fixed widths. |
snap | boolean | true | Whether the row settles at an item when a scroll ends; false lets it rest wherever the scroll ends. |
loop | boolean | false | Whether the row is endless: scrolling past the last item continues to the first, and back. Takes effect only with two or more items; with fewer it is ignored. |
navigation | auto | always | none | "auto" | Whether the previous and next controls are drawn over the ends of the row (CRL-41, CRL-42). auto draws them where the primary pointer is fine and can hover — a mouse or a trackpad, where no finger swipes the row — and shows them while the pointer is over the carousel or focus is within it; always draws them on every device and shows them at all times; none draws neither. Keep auto wherever you can: without the controls a person with a mouse moves the row only with Shift and the wheel, or with the indicator where it is drawn, and never with a single press (WCAG 2.5.7). |
indicator | boolean | false | Whether the dots are drawn below the items: one per resting position, the current one stretched. For a short featured row; a long row to browse needs none. |
autoplay | boolean | false | Whether the row advances by itself, one item every autoplayInterval. It holds while the carousel is hovered, has focus within, is pressed or is hidden, and never runs where motion is reduced (CRL-32 to CRL-34). |
autoplayInterval | number | null | How long the row rests at an item before autoplay moves on, in milliseconds; null takes comp.carousel.autoplay.interval. Give text-heavy items more time than images. |
paused | boolean | false | Whether autoplay is paused, by the person (with the playback control) or by the product. The playback control changes it and emits pausedChange; a product that sets it emits nothing. |
playbackControl | boolean | true | Whether the playback control is drawn while autoplay is on. A product may hide it, but should keep it wherever it can: on touch there is no hover, and without it a person cannot stop the motion (WCAG 2.2.2). |
autoplayProgress | boolean | false | Whether the current dot fills to show the time until autoplay moves on. Needs indicator; ignored while autoplay is off or paused. |
playLabel | string | "" | The playback control's accessible name while autoplay is paused ("Play the slideshow"). Required while the control can be drawn. |
pauseLabel | string | "" | The playback control's accessible name while autoplay is playing ("Pause the slideshow"). Required while the control can be drawn. |
previousLabel | string | "" | The previous control's accessible name ("Previous walk"). Required while the control can be drawn. |
nextLabel | string | "" | The next control's accessible name ("Next walk"). Required while the control can be drawn. |
label | string | "" | Names the carousel's list, and its indicator, for assistive technology ("Recently played"). Required. |
इवेंट
| इवेंट | विवरण |
|---|---|
pausedChange | The person paused or played autoplay with the playback control; carries the new paused value. Not emitted when the product sets paused, nor for the holds of CRL-33. |
आइटम
वे आइटम के प्रकार जिन्हें कंपोनेंट दोहराता है। फ़िक्स्चर अपने आइटम क्रम से सूचीबद्ध करता है; हर प्लैटफ़ॉर्म हर प्रकार को अपने तरीक़े से नाम देता है।
item
One item of the row: the product's content in a rounded box, one action named by its label.
| प्रॉपर्टी | टाइप | डिफ़ॉल्ट | विवरण |
|---|---|---|---|
label | string | "" | The item's accessible name: what its content shows ("Coast path, 12 photos"). Required; the content itself is not read. It is also the indicator's value text while the item is in focus. |
| स्लॉट | विवरण |
|---|---|
default | The item's content. A fixture item's content is the name of a glyph: the harness draws it centred in the content box (the hero's width, the row's height) at sys.icon.medium through the icon helper, with the family and fill of an unselected icon, in the item's content color, on the item's container color. |
| इवेंट | विवरण |
|---|---|
click | The item was activated by pointer, touch, keyboard or assistive technology. |
| स्पेक | Web | SwiftUI | Jetpack Compose | Flutter | React Native |
|---|---|---|---|---|---|
| आइटम | tanrei-carousel-item | TanreiCarouselItem | TanreiCarouselItem | TanreiCarouselItem | CarouselItem |
label · प्रॉपर्टी | label | label | label | label | label |
click · इवेंट | click | action | onClick | onTap | onPress |
| टिप्पणियाँ | A <tanrei-carousel-item> child; its content is its default slot. | TanreiCarouselItem(_ label: String, action: @escaping () -> Void) { content }. | TanreiCarouselItem(label, onClick) { content }, called from the carousel's item lambda. | TanreiCarouselItem(label:, onTap:, child:), one of the carousel's children. | <CarouselItem label onPress>{content}</CarouselItem>, a child of Carousel. |
स्टेट
व्यवहार
EARS रूप में लिखी गई आवश्यकताएँ। हर प्लैटफ़ॉर्म के इम्प्लीमेंटेशन को इन ID के आधार पर टेस्ट किया जाता है। आवश्यकताओं का पाठ स्पेक फ़ाइल से ज्यों का त्यों, अंग्रेज़ी में दिखाया गया है।
| ID | आवश्यकता |
|---|---|
CRL-1 | WHEN the user activates an item by pointer, touch, Enter or Space THE carousel SHALL emit that item's click exactly once; a press that turns into a scroll (a drag beyond the platform's touch slop, a fling) SHALL NOT activate the item it started on. |
CRL-2 | WHILE an item, the indicator or the playback control is hovered, keyboard-focused or pressed THE carousel SHALL render that part's container, content color and opacity, and an item's shape, from the component tokens of its highest-precedence active state, with precedence pressed over focused over hovered; focus gained by pointer or touch SHALL NOT select the focused state. |
CRL-3 | WHEN an item, the indicator or the playback control receives keyboard focus THE carousel SHALL show the focus ring without animation, inside an item's container, which the row would otherwise clip, and around the indicator's or the playback control's container; focus gained by pointer or touch SHALL NOT show it. |
CRL-4 | THE carousel SHALL make each item's hit area its drawn container with half of comp.carousel.layout.gap on each side, which for a small item at comp.carousel.container.small-min-width is sys.target.touch wide with the default tokens, and SHALL NOT let the hit area of an item that fills a slot fall below sys.target.pointer wide for a fine pointer or sys.target.touch for touch; a system whose widths give less SHALL still extend the hit area without changing the drawn item, and the row's height SHALL NOT be below the target either. An item on its way between the last slot and an edge slot (CRL-12) is narrower than any slot: its hit area SHALL be its drawn container with half of the gap on each side and no wider, so that it never covers its neighbour's. |
CRL-5 | WHEN a carousel item or the playback control is pressed by pointer, touch, Enter or Space, or the indicator by pointer or touch, THE carousel SHALL show that part's pressed state without delay and SHALL keep it visible for at least sys.motion.duration.press-hold, even when the press ends sooner; the indicator's SHALL last as long as the press does. |
CRL-6 | WHILE a carousel item, the indicator or the playback control is pressed THE carousel SHALL answer as sys.behavior.pressed-feedback names: overlay applies the pressed tokens to the whole container at once; ripple grows the pressed state layer from the point of contact (from the center for keyboard activation); dim applies the pressed opacity to the whole control and draws no state layer; none draws no answer to the press. Under ripple and dim only the container color stays with the state under the press; content color, opacity and shape still come from the pressed tokens. Under none every part stays with the state under the press. The ripple grows over comp.carousel.motion.feedback-duration with comp.carousel.motion.state-easing, fades over comp.carousel.motion.state-duration with comp.carousel.motion.state-easing once the press has ended and press-hold has passed, and appears whole where motion is reduced. |
CRL-7 | THE carousel SHALL ease the corners of its items' containers, the indicator's container and the playback control by sys.shape.corner-smoothing (0 is a quarter circle, 0.6 the iOS continuous corner; a platform with only the OS curve draws it for any amount above 0) and show keyboard focus as sys.behavior.focus-style names (ring or glow); a platform that cannot draw a choice SHALL fall back to the first value and state that in its README. |
CRL-8 | THE carousel SHALL be as wide as its parent; its row of items SHALL be comp.carousel.layout.height tall unless the product sizes the carousel through the platform's own sizing, in which case the row takes that height less the controls row (CRL-28), and every item SHALL be as tall as the row. It SHALL lay its items out in one row in the order given, comp.carousel.layout.gap apart (g), inside comp.carousel.layout.padding-inline at its start and its end: the inner width W is the carousel's width less that padding twice. Items SHALL scroll under the padding to the carousel's edges and be clipped there. |
CRL-9 | THE carousel SHALL take L from itemWidth, or from comp.carousel.container.large-width while itemWidth is null, and SHALL make the hero slot H wide. WHILE fluidWidth is false H SHALL be L, at most W. WHILE fluidWidth is true H SHALL be L kept between a floor and a cap: WHILE heroAlignment is center, the floor (W − 4 × g − 2 × comp.carousel.container.small-max-width) / 3 and the cap W − 2 × (g + comp.carousel.container.small-max-width); WHILE heroAlignment is start, the floor (W − 2 × g − comp.carousel.container.small-max-width) / 2 and the cap W − g − comp.carousel.container.small-max-width. IF fluidWidth is true and that cap is less than comp.carousel.container.small-max-width THE carousel SHALL lay the row out as it does with fixed widths (CRL-13), H being W. |
CRL-10 | WHILE fluidWidth is true THE carousel SHALL fill the width E that the hero slot leaves on each side where items follow it (on both sides, E = (W − H) / 2 − g, WHILE heroAlignment is center; after it, E = W − H − g, WHILE heroAlignment is start) with slots g apart, going outward from the hero: IF E − g is less than 2 × comp.carousel.container.small-min-width, one small slot E wide; otherwise a medium slot M wide and then a small slot S wide, where S is (E − g) / 3 kept between comp.carousel.container.small-min-width and comp.carousel.container.small-max-width and M = E − g − S. IF M is then greater than H, M SHALL be H and S SHALL be E − g − H. Widths SHALL NOT be rounded before the items are placed; CRL-40 says where a platform that draws on whole device pixels puts the rounding. |
CRL-11 | THE carousel SHALL place the hero slot, where the item in focus sits, WHILE heroAlignment is center with its middle at the middle of the inner width (its start h at (W − H) / 2), and WHILE heroAlignment is start at the inner start edge (h is 0); and SHALL place the other slots of CRL-10, on both sides of it at the centre and after it at the start, each one g beyond the slot before it going outward, measured between the slots' drawn edges. |
CRL-12 | THE carousel SHALL place its items by a scroll position p, a number of items that advances by one for every H + g the row is scrolled. WHILE loop is not in effect (CRL-27) p SHALL run from 0 to N − 1 (N the number of items), except where CRL-13 ends the range sooner for a hero at the start; the resting positions are the whole numbers in the range and, where the range ends at a fraction, its end, D of them in all, so D is N wherever the range is not ended sooner. Item i, counted from 0, sits at slot position s = i − p. Slot 0 is the hero slot and slots 1, 2 and on follow it toward the end; WHILE heroAlignment is center slots −1, −2 and on precede it toward the start, and WHILE heroAlignment is start no slot precedes it (CRL-10, CRL-11, CRL-13). WHILE fluidWidth is true, beyond the last slot on each side lies an edge slot of no width, g beyond that slot — before a hero at the start, g before the hero slot itself — so that at a whole p nothing is drawn beyond the last slots; an item at or beyond an edge slot SHALL NOT be drawn. An item's start and width SHALL be the linear interpolation between those of the two slots around s. So at p = 0 the first item is the hero and nothing is drawn before it, and as p grows each item moves toward the start, growing from nothing at the edge slot to H as it reaches slot 0 and narrowing again to nothing as it leaves, a hero at the start narrowing against the inner start edge; at the end of the range the last item is the hero and the slots after it are empty. |
CRL-13 | WHILE fluidWidth is false THE carousel SHALL make every slot H wide, slot k starting at h + k × (H + g), h being the hero slot's start (CRL-11), with no edge slot: the slots go on beyond the carousel's edges, where the items are clipped (CRL-8), so that CRL-12's interpolation starts item i at h + s × (H + g). WHILE scaleOthers is also true the slots other than the hero's take the widths and the places CRL-26 gives them. WHILE heroAlignment is start, scaleOthers is false and loop is not in effect, the range of p SHALL end where the last item ends at the inner end edge, at the greater of 0 and (N × (H + g) − g − W) / (H + g), so that WHILE every item fits in W the row does not scroll. |
CRL-14 | WHEN the user scrolls the carousel by touch, pen, trackpad, a horizontal wheel or Shift with a vertical wheel THE carousel SHALL follow the scroll; WHILE snap is true, WHEN the scroll ends (a drag released, a wheel or trackpad gesture over) THE carousel SHALL settle at a resting position: the next one in the direction of a fling, or else the nearest one, over comp.carousel.motion.scroll-duration with comp.carousel.motion.scroll-easing, at once where motion is reduced; WHILE snap is false it SHALL come to rest wherever the scroll ends. A fling is a release faster than the platform's minimum fling velocity (Android's ViewConfiguration.getScaledMinimumFlingVelocity, Flutter's kMinFlingVelocity) or, where the platform names none (the web, SwiftUI, React Native), 0.5 points per millisecond. A release's velocity is the pointer's over its last moves: WHERE the pointer has not moved for longer than the time after which the platform's velocity tracker takes a pointer as stopped (40 milliseconds in Android's VelocityTracker, Jetpack Compose's VelocityTracker and Flutter's VelocityTracker) or, where the platform names none (the web, SwiftUI, React Native), 40 milliseconds before the release THE carousel SHALL take the release as having no velocity, so that a drag that stops where it is wanted and is let go there is no fling, however fast it moved before it stopped. A horizontal wheel, a trackpad and Shift with a vertical wheel are physical in every layout direction: THE carousel SHALL move the row the way the platform's own scrolling containers move for that input and SHALL NOT reverse it in a right-to-left layout, so that Shift with a wheel turned down, which brings into view what lies further to the right, moves toward later items in left-to-right and toward earlier items in right-to-left. |
CRL-15 | THE carousel SHALL lay each item's content out H wide and as tall as the row, and SHALL clip it to the item's container and its comp.carousel.container.shape corners; WHILE fluidWidth is false or contentAlignment is center the content SHALL be centred on the container, and WHILE fluidWidth is true and contentAlignment is toward-hero an item after the hero (s above 0) SHALL align the content's start edge with its container's start edge and an item before it (s below 0) the content's end edge with its container's end edge, so that a narrowed item shows the side of its content nearest the hero and the content glides inside the item as it widens and narrows. |
CRL-16 | THE carousel SHALL fill each item's container with comp.carousel.item.container.color at rest, under its content, whatever the item's state, and SHALL hand the content comp.carousel.item.content.color as the platform's inherited foreground (the web's inherited color, SwiftUI's foreground style, Compose's content color, Flutter's default text and icon style, React Native's Tanrei text context). Because an item's content usually covers it (an image), the carousel SHALL draw the state layer over the content: comp.carousel.item.state-layer.color at sys.state.hover-state-layer-opacity, sys.state.focus-state-layer-opacity or sys.state.pressed-state-layer-opacity for the item's highest-precedence state, and the ripple of CRL-6 in the same layer, so hover, focus and press show on any content; the container color under the content is the resting fill only. |
CRL-17 | THE carousel SHALL be at most five Tab stops, in this order: the playback control while it is drawn (CRL-35), so that the motion can be stopped before anything else is reached; the previous and then the next control while they are drawn (CRL-41), before the items, so that a person can move the row before reading it; the items, as one stop, at the item that last had keyboard focus in it or else at the resting item (the item at slot 0 while fluidWidth is true, heroAlignment is center or snap is true, and otherwise the first item wholly in view); and the indicator while it is drawn (CRL-29). WHILE an item has keyboard focus Right Arrow and Left Arrow SHALL move focus to the next and previous item, from the last to the first and the first to the last WHILE loop is in effect and otherwise without wrapping, and Home and End to the first and last item; in a right-to-left layout Left Arrow SHALL move to the next item and Right Arrow to the previous. |
CRL-18 | WHEN an item receives keyboard focus or assistive-technology focus THE carousel SHALL scroll, over comp.carousel.motion.scroll-duration with comp.carousel.motion.scroll-easing (at once where motion is reduced), so that WHILE fluidWidth is true, heroAlignment is center or snap is true the item sits at slot 0 or, where the range ends first, at the resting position nearest it, going the shorter way round WHILE loop is in effect; and otherwise so that the whole item is in view, scrolling as little as that needs. |
CRL-19 | THE carousel SHALL expose its items as a list named by label, and each item as one element with the button role, named by its label, with its position among the items and their number; it SHALL hide each item's content from assistive technology (the label names the item), and SHALL keep items that are out of view exposed, in order, so that a screen reader reaches every item (CRL-18 brings it into view). The indicator (CRL-31), the playback control (CRL-35) and the previous and next controls (CRL-41) SHALL be outside the list and SHALL NOT be counted among its items. |
CRL-20 | WHILE an item's label is empty THE carousel SHALL still render it, and in debug builds report that it has no accessible name; WHILE the carousel's label is empty it SHALL report that the list and the indicator have no name; WHILE autoplay and playbackControl are true and playLabel or pauseLabel is empty it SHALL report the missing name; WHILE the previous and next controls are drawn (CRL-41) and previousLabel or nextLabel is empty it SHALL report the missing name; and WHILE indicator is true and the dots do not fit (CRL-29) it SHALL report that they are not drawn. An item's content SHALL contain no interactive element; a platform that can inspect it (the web, on every slot change) SHALL report one in debug builds, and a platform that cannot SHALL state the rule in its README. |
CRL-21 | WHEN the carousel's width or its items change THE carousel SHALL arrange its slots again and keep the resting item (CRL-17) where it was, as far as the new range allows, without motion; WHEN the number of items falls below two it SHALL stop looping (CRL-27) and advancing (CRL-32), and no longer draw the indicator, the playback control or the previous and next controls. |
CRL-22 | WHEN the colors of an item, the indicator or the playback control change between states THE carousel SHALL animate them over comp.carousel.motion.state-duration with comp.carousel.motion.state-easing, and SHALL change them at once where motion is reduced. |
CRL-23 | WHEN the layout direction is right-to-left THE carousel SHALL mirror its row and its controls row: the inner start edge at the right, items moving toward the right as p grows, the padding, the scroll direction, the start and end sides of contentAlignment, the order of the dots, the playback control's side and the sides of the previous and next controls (the previous control at the right) all mirrored; it SHALL grow a ripple from the point of contact as in left-to-right, and SHALL NOT mirror an item's content or the pause and play_arrow glyphs. The chevron_left and chevron_right glyphs of the previous and next controls SHALL be drawn mirrored exactly when the system's icon set marks the name as mirrored, by the Button's own icon helper; THE carousel SHALL NOT mirror a glyph itself. |
CRL-24 | WHEN heroAlignment, contentAlignment or navigation names a value the carousel does not define THE carousel SHALL render with that prop's default value, and in debug builds report the unknown value; WHEN itemWidth or autoplayInterval is not a positive number THE carousel SHALL treat it as null and in debug builds report it. |
CRL-25 | WHILE the text size is enlarged THE carousel SHALL keep its height, slots and items as they are: it holds no text of its own, and an item's content follows the text size itself. |
CRL-26 | WHILE scaleOthers is true THE carousel SHALL give the hero slot the scale 1 and every other slot the scale comp.carousel.container.min-scale, and SHALL draw each item's container at the scale interpolated between the two slots around s, which is 1 − (1 − comp.carousel.container.min-scale) × the lesser of 1 and |s|: as tall as the row times that scale, centred on the row's height, with its content drawn at that scale. WHILE fluidWidth is false a slot SHALL also be H times its scale wide, and the slots SHALL be placed g apart from drawn edge to drawn edge going outward from the hero slot, so that the smaller items close up to their neighbours; WHILE fluidWidth is true the slots keep the widths of CRL-10, which already fill the row, and only the height and the content take the scale. The corners of a scaled container SHALL stay the radius of comp.carousel.container.shape (or of its state's shape token) and SHALL NOT be multiplied by the scale; the item's focus ring SHALL be drawn at its own width inside the drawn container, and the item's hit area (CRL-4) SHALL follow the drawn container. The scale SHALL follow the scroll where motion is reduced as well, because the person's own scroll drives it. |
CRL-27 | WHILE loop is true and there are at least two items THE carousel SHALL scroll without end in both directions: p SHALL take any value, every whole number SHALL be a resting position, and item i SHALL sit at the one slot position s that differs from i − p by a whole multiple of N and lies above −N / 2 and at most N / 2 WHILE heroAlignment is center, or above −1 and at most N − 1 WHILE heroAlignment is start, so that scrolling past the last item continues to the first and before the first to the last. Each item SHALL be drawn once: with fluid widths and enough items for every slot and both edge slots an item passes from one side to the other at the edge slots, where it has no width, and with fewer items, or with fixed widths and too few items to reach beyond both edges, a slot stays empty and an item that passes to the other side may appear there at once. WHILE there are fewer than two items THE carousel SHALL ignore loop; loop is in effect only while both conditions hold. |
CRL-28 | WHILE the indicator (CRL-29) or the playback control (CRL-35) is drawn THE carousel SHALL draw, directly below its row of items, a controls row as wide as the carousel and comp.carousel.controls.height tall that does not scroll, with the indicator's container centred on the carousel's width and the playback control at its inline end, its end edge at the inner end edge, both centred on the row's height; WHILE neither is drawn there SHALL be no controls row. The indicator SHALL stay centred whether or not the playback control is drawn. |
CRL-29 | WHILE indicator is true and there are at least two resting positions THE carousel SHALL draw the indicator: D dots in reading order, comp.carousel.dot.gap apart, each comp.carousel.dot.size tall with round ends, inside a container that reaches comp.carousel.controls.indicator-padding-inline beyond the first and last dot, is comp.carousel.controls.button-size tall and has comp.carousel.controls.shape corners. The indicator's position q follows p: between resting positions j and j + 1 it runs linearly from j to j + 1, and WHILE loop is in effect q is p less a whole multiple of N, from 0 up to N, its distance to a dot measured around the ring. Dot j SHALL be comp.carousel.dot.size + (comp.carousel.dot.active-width − comp.carousel.dot.size) × w wide, w being the greater of 0 and 1 − the distance from q to j, and SHALL be drawn in comp.carousel.dot.color with a fill of comp.carousel.indicator.content.color over it at opacity w, across its whole width unless CRL-36 says otherwise, so that the current dot is stretched and in the active color and the stretch and the color pass to the next dot as the row scrolls. IF the container would be wider than W − 2 × (sys.target.touch + g) THE carousel SHALL NOT draw the indicator. |
CRL-30 | WHEN the person presses the indicator by pointer or touch anywhere in its hit area THE carousel SHALL move the row to the resting position of the dot nearest the press and, while the press moves along the dots, to the dot nearest it, each move over comp.carousel.motion.scroll-duration with comp.carousel.motion.scroll-easing (at once where motion is reduced); WHILE the indicator has keyboard focus Right Arrow and Left Arrow SHALL move the row to the next and previous resting position (wrapping WHILE loop is in effect, and otherwise not), Home and End to the first and last, mirrored in a right-to-left layout; WHEN assistive technology increments or decrements the indicator it SHALL move by one resting position. Focus SHALL stay on the indicator, and the items' Tab stop (CRL-17) SHALL become the resting item the move brings. |
CRL-31 | THE carousel SHALL expose the indicator as one slider (the adjustable trait on Apple platforms), named by label, horizontal, with the lowest value 1, the highest D and the value of the resting position nearest q counted from 1, and SHALL give it as value text the label of the item that position brings to slot 0 or, where the range ends first, the resting item there; its dots SHALL NOT be exposed one by one. |
CRL-32 | WHILE autoplay is true, paused is false, there are at least two resting positions, motion is not reduced (CRL-34) and no hold of CRL-33 is in effect THE carousel SHALL advance to the next resting position each time autoplayInterval (or comp.carousel.autoplay.interval while it is null) has passed with the row at rest, scrolling over comp.carousel.motion.autoplay-duration with comp.carousel.motion.autoplay-easing; from the last resting position it SHALL go on to the first, forward WHILE loop is in effect and otherwise back across the row over the same duration. An advance SHALL NOT move focus, change the items' Tab stop, or make an announcement. |
CRL-33 | WHILE a pointer is over the carousel (its row or its controls row), focus is anywhere within it however it came there, the person is pressing or dragging the row or the indicator, or the platform reports the carousel's window or document hidden, THE carousel SHALL NOT advance and SHALL hold the time that has passed; WHEN the last hold ends it SHALL continue from the time it held. WHEN the person moves the row (a scroll, a key, the indicator, the previous or the next control) the time SHALL start again from zero once the row comes to rest. WHEN the person activates the playback control to play, the hover and focus holds in effect at that moment SHALL end, and each SHALL apply again only once the pointer or focus has left the carousel and entered it again. |
CRL-34 | WHILE motion is reduced THE carousel SHALL NOT advance by itself, whatever autoplay and paused say, and SHALL NOT draw the playback control or the autoplay progress; WHEN motion stops being reduced it SHALL start autoplay again (paused permitting) with the time from zero. Where motion is reduced the width, the scale and the dots SHALL still follow a scroll the person makes. |
CRL-35 | WHILE autoplay is true, playbackControl is true, there are at least two resting positions and motion is not reduced THE carousel SHALL draw the playback control in the controls row: an icon-only button, a comp.carousel.controls.button-size square with comp.carousel.controls.shape corners, filled with comp.carousel.playback.container.color, holding the icon set's pause glyph while paused is false and play_arrow while paused is true, comp.carousel.controls.icon.size, in comp.carousel.playback.content.color, with the family and fill of an unselected icon, sys.icon.weight and its optical size clamped to sys.icon.optical-size.min and sys.icon.optical-size.max. It SHALL be exposed with the button role, named by pauseLabel while paused is false and by playLabel while paused is true, with no pressed or selected state. WHEN the person activates it THE carousel SHALL toggle paused, emit pausedChange with the new value and keep focus on it, and on play the time SHALL start from zero; WHEN the product sets paused THE carousel SHALL emit nothing. |
CRL-36 | WHILE autoplayProgress is true, the indicator is drawn, autoplay is true, paused is false and motion is not reduced THE carousel SHALL draw the fill of CRL-29 only on the dot of the resting position the row last came to rest at, from that dot's start edge across the part of its width that the time passed (CRL-33) is of the interval, growing with the time and stopping while a hold is in effect, and on no other dot, so that the dot stands in comp.carousel.dot.color and fills with comp.carousel.indicator.content.color until the row moves on, the fill fading as the dot narrows. |
CRL-37 | THE carousel SHALL give the playback control a hit area centred on it of at least sys.target.touch for touch and sys.target.pointer for a fine pointer, and the indicator a hit area as tall as the controls row and as wide as its container, at least sys.target.touch wide; with the default tokens both fit inside the controls row, and CRL-29 keeps them apart. |
CRL-38 | WHILE the icon set's font has not loaded THE carousel SHALL keep the playback control's glyph box and draw nothing in it, never the glyph's name as text. |
CRL-39 | THE carousel SHALL take its layout direction from where it is used — the direction of the nearest ancestor that sets one, and the platform's own where none does — and SHALL have no direction setting of its own; WHEN that direction changes while the carousel is shown THE carousel SHALL draw itself for the new direction at once, without a motion of its own, keeping the item at rest (the same item in reading order, not the same scroll offset), its playback and its focus. |
CRL-40 | THE carousel SHALL keep the distance from the drawn end edge of an item's container to the drawn start edge of the next item's container equal to comp.carousel.layout.gap, for every two neighbouring items that are both drawn, at every scroll position: at rest and at every moment of a drag, a fling, a settle, an advance and a move by the keys or the dots, in every combination of heroAlignment, fluidWidth, scaleOthers, contentAlignment, snap and loop, and in both layout directions. The edges are those of the container as it is drawn, after any scale (CRL-26), not those of a box laid out before the scale. THE carousel SHALL place every item it draws in a frame from the same scroll position p, and SHALL NOT ease, delay or animate an item's start, width or scale apart from p. A platform that draws on whole device pixels SHALL round each item's start edge and take its end edge from the next item's rounded start edge less the gap as that platform rounds it, so that the rounding falls on an item's width and never on a gap, and no two gaps in view differ. |
CRL-41 | WHILE navigation is auto or always and there are at least two resting positions THE carousel SHALL draw a previous control over the inline start of its row and a next control over its inline end, above the items: the previous control's start edge at the inner start edge and the next control's end edge at the inner end edge, both centred on the row's height. They SHALL be icon-only Buttons of the medium size in the variant comp.carousel.navigation.button.variant names, given through the channel a Button reads from the component that places it and otherwise unrestyled, showing the icon set's chevron_left and chevron_right glyphs and named by previousLabel and nextLabel. WHILE navigation is auto THE carousel SHALL draw them only where the primary pointer is fine and can hover; WHILE navigation is none, or there are fewer than two resting positions, it SHALL draw neither. |
CRL-42 | WHILE navigation is auto THE carousel SHALL show the previous and next controls only while a pointer is over the carousel (its row or its controls row) or focus is within it, however it came there, fading them in and out over comp.carousel.motion.state-duration with comp.carousel.motion.state-easing, at once where motion is reduced; hidden, they SHALL keep their place in the Tab order (CRL-17) and stay exposed to assistive technology with their names and states, so that a keyboard reaches them and focus shows them. WHILE navigation is always THE carousel SHALL show them at all times. |
CRL-43 | WHEN the person activates the previous or the next control THE carousel SHALL move the row to the resting position before or after the one it is at — while it is moving, the one it is moving to; between two resting positions, the nearest one before or after where it is — over comp.carousel.motion.scroll-duration with comp.carousel.motion.scroll-easing (at once where motion is reduced), from the first to the last and from the last to the first WHILE loop is in effect. Focus SHALL stay on the control, and the items' Tab stop (CRL-17) SHALL become the resting item the move brings. WHILE loop is not in effect THE carousel SHALL disable the previous control while the row is at, or moving to, the first resting position, and the next control at the last: drawn and exposed as disabled and refusing activation, but kept in the Tab order and keeping focus, so that the stops do not change as the row moves and focus is never lost when a control reaches its end. |
प्लैटफ़ॉर्म के अनुसार नामों का मिलान
पैरिटी का मतलब एक जैसे API नहीं है। हर प्लैटफ़ॉर्म एक ही कॉन्ट्रैक्ट को अपने तरीक़े से व्यक्त करता है।
| स्पेक | Web | SwiftUI | Jetpack Compose | Flutter | React Native |
|---|---|---|---|---|---|
| कंपोनेंट | tanrei-carousel | TanreiCarousel | TanreiCarousel | TanreiCarousel | Carousel |
heroAlignment · प्रॉपर्टी | heroAlignment | heroAlignment | heroAlignment | heroAlignment | heroAlignment |
itemWidth · प्रॉपर्टी | itemWidth | itemWidth | itemWidth | itemWidth | itemWidth |
fluidWidth · प्रॉपर्टी | fluidWidth | fluidWidth | fluidWidth | fluidWidth | fluidWidth |
contentAlignment · प्रॉपर्टी | contentAlignment | contentAlignment | contentAlignment | contentAlignment | contentAlignment |
scaleOthers · प्रॉपर्टी | scaleOthers | scaleOthers | scaleOthers | scaleOthers | scaleOthers |
snap · प्रॉपर्टी | snap | snap | snap | snap | snap |
loop · प्रॉपर्टी | loop | loop | loop | loop | loop |
navigation · प्रॉपर्टी | navigation | navigation | navigation | navigation | navigation |
indicator · प्रॉपर्टी | indicator | showsIndicator | indicator | indicator | indicator |
autoplay · प्रॉपर्टी | autoplay | autoplay | autoplay | autoplay | autoplay |
autoplayInterval · प्रॉपर्टी | autoplayInterval | autoplayInterval | autoplayInterval | autoplayInterval | autoplayInterval |
paused · प्रॉपर्टी | paused | isPaused | paused | paused | paused |
playbackControl · प्रॉपर्टी | playbackControl | showsPlaybackControl | playbackControl | playbackControl | playbackControl |
autoplayProgress · प्रॉपर्टी | autoplayProgress | showsAutoplayProgress | autoplayProgress | autoplayProgress | autoplayProgress |
playLabel · प्रॉपर्टी | playLabel | playLabel | playLabel | playLabel | playLabel |
pauseLabel · प्रॉपर्टी | pauseLabel | pauseLabel | pauseLabel | pauseLabel | pauseLabel |
previousLabel · प्रॉपर्टी | previousLabel | previousLabel | previousLabel | previousLabel | previousLabel |
nextLabel · प्रॉपर्टी | nextLabel | nextLabel | nextLabel | nextLabel | nextLabel |
label · प्रॉपर्टी | label | label | contentDescription | semanticLabel | accessibilityLabel |
pausedChange · इवेंट | pausedchange | isPaused | onPausedChange | onPausedChanged | onPausedChange |
| टिप्पणियाँ | Attributes: hero-alignment, item-width (a number of CSS pixels; without it the property is null), content-alignment, scale-others, loop, indicator, autoplay, autoplay-interval (milliseconds), paused, autoplay-progress, play-label, pause-label, navigation (reflected), previous-label, next-label. fluidWidth, snap and playbackControl are boolean properties that default to true; their attributes are the inverses fixed-width, free-scroll and no-playback-control (an HTML boolean attribute cannot default to true). pausedchange is a CustomEvent whose detail.paused is the new value. Built on a native horizontal scroller (so wheel, trackpad and touch scroll as the platform does) whose track is as long as the scroll range; the items are placed from its scroll offset (CRL-12), and the settle animates the scroll offset over comp.carousel.motion.scroll-duration and scroll-easing once the scroll ends (scrollend, or 100 ms without a scroll event, because not every engine sends scrollend after a wheel), since a smooth scrollTo cannot follow the tokens. Fling 0.5 px/ms, measured from the finger's last touch moves over their own time stamps; after a fling the settle starts at the release, and the browser's momentum is held until it ends. While loop is in effect the track is several turns long and the offset is moved by a whole number of turns (N × (H + g)) when the row rests near either end, which draws nothing new. Autoplay reads prefers-reduced-motion and document.visibilityState when it would advance and listens for their changes; the hover hold is pointerenter / pointerleave on the host, the focus hold focusin / focusout. The items are placed from one scroll position in one pass, each start rounded to a device pixel and each end taken from the next start (CRL-40). The previous and next controls are <tanrei-button> elements with focusable-when-disabled, given their variant through the Button's group-item channel; auto draws them under (hover: hover) and (pointer: fine) and shows them while the host matches :hover or :focus-within. Snapshot harness: a 400 × 200 stage (the carousel fills it: W 368), or 400 × 248 for the fixtures with a controls row, on a surface page, scrolled to its start, the pointer outside, motion not reduced and the autoplay clock stopped at the start of its interval. | Lagging: ships an earlier revision of this spec, with layout and its three values, and no loop, dots or autoplay, and so owes the hero centred by default, the edge slots of no width, the scaled slots closed up and the constant gap as well (CRL-9 to CRL-13, CRL-26, CRL-40), and the previous and next controls with their props navigation, previousLabel and nextLabel (CRL-41 to CRL-43). Target API: TanreiCarousel(_ label: String, heroAlignment: .center, itemWidth: CGFloat? = nil, fluidWidth: true, contentAlignment: .center, scaleOthers: false, snap: true, loop: false, showsIndicator: false, autoplay: false, autoplayInterval: Duration? = nil, isPaused: Binding<Bool>, showsPlaybackControl: true, showsAutoplayProgress: false, playLabel:, pauseLabel:) { TanreiCarouselItem(…) { … } }; pausedChange is the isPaused binding, set only by the control. A horizontal ScrollView whose content is a track as long as the scroll range, the items placed from the scroll offset by a custom Layout (read from scrollPosition and the track's geometry), settled by a custom ScrollTargetBehavior (iOS 17). The list is an accessibilityElement(children: .contain) named by label, and each item a button. SwiftUI has no position-in-set property for a custom container, so VoiceOver's own count of the container's elements stands in; the README says so. Autoplay reads accessibilityReduceMotion and scenePhase. Snapshot harness: a 400 × 200 frame (400 × 248 with a controls row) on a surface page. | Lagging: ships an earlier revision of this spec, with layout and its three values, and no loop, dots or autoplay, and so owes the hero centred by default, the edge slots of no width, the scaled slots closed up and the constant gap as well (CRL-9 to CRL-13, CRL-26, CRL-40), and the previous and next controls with their props navigation, previousLabel and nextLabel (CRL-41 to CRL-43). Target API: TanreiCarousel(itemCount, contentDescription, heroAlignment, itemWidth: Dp? = null, fluidWidth = true, contentAlignment, scaleOthers = false, snap = true, loop = false, indicator = false, autoplay = false, autoplayInterval: Duration? = null, paused = false, onPausedChange, playbackControl = true, autoplayProgress = false, playLabel, pauseLabel) { index -> TanreiCarouselItem(…) { … } }, as Material's carousels take an item lambda; built on Modifier.scrollable and a custom Layout, not Material's carousel (the package does not depend on Material). Settling uses a SnapFlingBehavior whose fling threshold is ViewConfiguration's. No list role: collectionInfo on the row and collectionItemInfo with Role.Button on each item. Autoplay reads the animator duration scale (0 is reduced motion) and the lifecycle's resumed state. Snapshot harness: a 400 × 200 dp box (400 × 248 with a controls row) on a surface page. | Lagging: ships an earlier revision of this spec, with layout and its three values, and no loop, dots or autoplay, and so owes the hero centred by default, the edge slots of no width, the scaled slots closed up and the constant gap as well (CRL-9 to CRL-13, CRL-26, CRL-40), and the previous and next controls with their props navigation, previousLabel and nextLabel (CRL-41 to CRL-43). Target API: TanreiCarousel(semanticLabel:, heroAlignment: TanreiCarouselHeroAlignment.center, itemWidth: null, fluidWidth: true, contentAlignment: TanreiCarouselContentAlignment.center, scaleOthers: false, snap: true, loop: false, indicator: false, autoplay: false, autoplayInterval: null, paused: false, onPausedChanged:, playbackControl: true, autoplayProgress: false, playLabel:, pauseLabel:, children: [...]), built on the widgets library's Scrollable with a custom layout and ScrollPhysics that settle (CRL-14), not Material's CarouselView. Each item is Semantics(button: true, label:) inside IndexedSemantics, and the scrollable reports semanticChildCount, so the position and the number of items are read; the whole is a Semantics(label:, explicitChildNodes: true) container. Autoplay reads MediaQuery.disableAnimationsOf and the app lifecycle. Snapshot harness: a golden of a 400 × 200 surface (400 × 248 with a controls row) on a surface page. | Lagging: ships an earlier revision of this spec, with layout and its three values, and no loop, dots or autoplay, and so owes the hero centred by default, the edge slots of no width, the scaled slots closed up and the constant gap as well (CRL-9 to CRL-13, CRL-26, CRL-40), and the previous and next controls with their props navigation, previousLabel and nextLabel (CRL-41 to CRL-43). Target API: <Carousel accessibilityLabel heroAlignment itemWidth fluidWidth contentAlignment scaleOthers snap loop indicator autoplay autoplayInterval paused onPausedChange playbackControl autoplayProgress playLabel pauseLabel>{items}</Carousel>: a horizontal ScrollView whose content is as long as the scroll range, the items placed from an Animated value of its offset; it settles with scrollTo after the drag or momentum ends (fling 0.5 pt/ms). The carousel has role="list" and each item the button role. React Native has no position-in-set property, so an item's position and the number of items are left to the screen reader's own count of the list; the README says so. Autoplay reads AccessibilityInfo.isReduceMotionEnabled and AppState. No virtualization. Snapshot harness: a 400 × 200 view (400 × 248 with a controls row) on a surface page. |
टोकन
| टोकन | किसका एलियास | रिज़ॉल्व किया गया मान (लाइट) |
|---|---|---|
--tanrei-comp-carousel-autoplay-interval | — | 5000ms |
--tanrei-comp-carousel-container-large-width | — | 200px |
--tanrei-comp-carousel-container-min-scale | — | 0.85 |
--tanrei-comp-carousel-container-shape | sys.shape.corner.large | 12px |
--tanrei-comp-carousel-container-small-max-width | — | 56px |
--tanrei-comp-carousel-container-small-min-width | — | 40px |
--tanrei-comp-carousel-controls-button-size | — | 40px |
--tanrei-comp-carousel-controls-height | sys.target.touch | 48px |
--tanrei-comp-carousel-controls-icon-size | sys.icon.medium | 24px |
--tanrei-comp-carousel-controls-indicator-padding-inline | sys.space.space150 | 12px |
--tanrei-comp-carousel-controls-shape | sys.shape.corner.full | 9999px |
--tanrei-comp-carousel-dot-active-width | — | 24px |
--tanrei-comp-carousel-dot-color | sys.color.outline | |
--tanrei-comp-carousel-dot-gap | sys.space.space100 | 8px |
--tanrei-comp-carousel-dot-size | — | 8px |
--tanrei-comp-carousel-focused-container-shape | — | 12px |
--tanrei-comp-carousel-focused-opacity | — | 1 |
--tanrei-comp-carousel-hovered-container-shape | — | 12px |
--tanrei-comp-carousel-hovered-opacity | — | 1 |
--tanrei-comp-carousel-indicator-container-color | — | |
--tanrei-comp-carousel-indicator-content-color | sys.color.primary | |
--tanrei-comp-carousel-indicator-focused-container-color | — | |
--tanrei-comp-carousel-indicator-focused-content-color | — | |
--tanrei-comp-carousel-indicator-focused-state-layer-color | — | |
--tanrei-comp-carousel-indicator-hovered-container-color | — | |
--tanrei-comp-carousel-indicator-hovered-content-color | — | |
--tanrei-comp-carousel-indicator-hovered-state-layer-color | — | |
--tanrei-comp-carousel-indicator-pressed-container-color | — | |
--tanrei-comp-carousel-indicator-pressed-content-color | — | |
--tanrei-comp-carousel-indicator-pressed-state-layer-color | — | |
--tanrei-comp-carousel-indicator-state-layer-color | comp.carousel.indicator.content.color | |
--tanrei-comp-carousel-item-container-color | sys.color.surface-container-highest | |
--tanrei-comp-carousel-item-content-color | sys.color.on-surface | |
--tanrei-comp-carousel-item-focused-container-color | — | |
--tanrei-comp-carousel-item-focused-content-color | — | |
--tanrei-comp-carousel-item-focused-state-layer-color | — | |
--tanrei-comp-carousel-item-hovered-container-color | — | |
--tanrei-comp-carousel-item-hovered-content-color | — | |
--tanrei-comp-carousel-item-hovered-state-layer-color | — | |
--tanrei-comp-carousel-item-pressed-container-color | — | |
--tanrei-comp-carousel-item-pressed-content-color | — | |
--tanrei-comp-carousel-item-pressed-state-layer-color | — | |
--tanrei-comp-carousel-item-state-layer-color | comp.carousel.item.content.color | |
--tanrei-comp-carousel-layout-gap | sys.space.space100 | 8px |
--tanrei-comp-carousel-layout-height | — | 200px |
--tanrei-comp-carousel-layout-padding-inline | sys.space.space200 | 16px |
--tanrei-comp-carousel-motion-autoplay-duration | sys.motion.duration.long2 | 500ms |
--tanrei-comp-carousel-motion-autoplay-easing | sys.motion.easing.standard | cubic-bezier(0.2, 0, 0, 1) |
--tanrei-comp-carousel-motion-feedback-duration | sys.motion.role.feedback | 450ms |
--tanrei-comp-carousel-motion-scroll-duration | sys.motion.duration.medium2 | 300ms |
--tanrei-comp-carousel-motion-scroll-easing | sys.motion.easing.emphasized-decelerate | cubic-bezier(0.05, 0.7, 0.1, 1) |
--tanrei-comp-carousel-motion-state-duration | sys.motion.role.state.large | 250ms |
--tanrei-comp-carousel-motion-state-easing | sys.motion.easing.state | cubic-bezier(0.2, 0, 0, 1) |
--tanrei-comp-carousel-navigation-button-variant | — | 2 |
--tanrei-comp-carousel-playback-container-color | — | |
--tanrei-comp-carousel-playback-content-color | sys.color.on-surface-variant | |
--tanrei-comp-carousel-playback-focused-container-color | — | |
--tanrei-comp-carousel-playback-focused-content-color | — | |
--tanrei-comp-carousel-playback-focused-state-layer-color | — | |
--tanrei-comp-carousel-playback-hovered-container-color | — | |
--tanrei-comp-carousel-playback-hovered-content-color | — | |
--tanrei-comp-carousel-playback-hovered-state-layer-color | — | |
--tanrei-comp-carousel-playback-pressed-container-color | — | |
--tanrei-comp-carousel-playback-pressed-content-color | — | |
--tanrei-comp-carousel-playback-pressed-state-layer-color | — | |
--tanrei-comp-carousel-playback-state-layer-color | comp.carousel.playback.content.color | |
--tanrei-comp-carousel-pressed-container-shape | — | 12px |
--tanrei-comp-carousel-pressed-opacity | — | 1 |
फ़िक्स्चर
मानक रेंडरिंग। हर प्लैटफ़ॉर्म हर फ़िक्स्चर का स्नैपशॉट एक ही ID से लेता है, ताकि नतीजों की तुलना की जा सके।
centered
previousLabel: Previous walk nextLabel: Next walk label: Featured walks items: 5 fixed-width
fluidWidth: false snap: false previousLabel: Previous walk nextLabel: Next walk label: Walks near you items: 5 scaled
fluidWidth: false scaleOthers: true loop: true previousLabel: Previous walk nextLabel: Next walk label: Featured walks items: 5 loop
loop: true previousLabel: Previous walk nextLabel: Next walk label: Featured walks items: 5 content-toward-hero
itemWidth: 120 contentAlignment: toward-hero loop: true previousLabel: Previous walk nextLabel: Next walk label: Walks near you items: 6 navigation
navigation: always previousLabel: Previous walk nextLabel: Next walk label: Featured walks items: 5 indicator
indicator: true previousLabel: Previous walk nextLabel: Next walk label: Featured walks items: 6 autoplay
indicator: true autoplay: true playLabel: Play the slideshow pauseLabel: Pause the slideshow previousLabel: Previous walk nextLabel: Next walk label: Featured walks items: 6 autoplay-progress
indicator: true autoplay: true autoplayProgress: true playLabel: Play the slideshow pauseLabel: Pause the slideshow previousLabel: Previous walk nextLabel: Next walk label: Featured walks items: 6 autoplay-paused
indicator: true autoplay: true paused: true autoplayProgress: true playLabel: Play the slideshow pauseLabel: Pause the slideshow previousLabel: Previous walk nextLabel: Next walk label: Featured walks items: 6 playback-control
autoplay: true playLabel: Play the slideshow pauseLabel: Pause the slideshow previousLabel: Previous walk nextLabel: Next walk label: Featured walks items: 4 इससे जनरेट किया गया: specs/carousel.spec.json, tokens/comp/carousel.tokens.json, design/tokens/
कैरसेल दृश्य आइटम की ऐसी पंक्ति के लिए इस्तेमाल करें जिसे लोग ब्राउज़ करते हैं और जिसके आइटम एक-एक करके खोलते हैं: एल्बम, जगहें, प्रॉडक्ट, एपिसोड। वह ग्रिड जितनी ऊँचाई लिए बिना दिखाता है कि आगे और आइटम हैं, और जो आइटम दिख रहे हैं उन्हें आने वाले आइटम से ज़्यादा जगह देता है।
जब आइटम ज़्यादातर टेक्स्ट हों, या जब लोग उनकी तुलना करते हों या उनमें से चुनते हों, तब लिस्ट इस्तेमाल करें। जब हर आइटम को अपना टेक्स्ट और अपनी क्रियाएँ चाहिए, तब ग्रिड में कार्ड इस्तेमाल करें। कैरसेल को सिर्फ़ छोटी फ़ीचर्ड पंक्ति के लिए अपने आप आगे बढ़ने दें, और उसका प्लेबैक कंट्रोल बनाए रखें।
हर प्रॉपर्टी एक सवाल का जवाब देती है, और वे आपस में खुलकर जोड़ी जा सकती हैं।
| प्रॉपर्टी | डिफ़ॉल्ट | यह क्या तय करती है |
|---|---|---|
heroAlignment |
center |
मुख्य आइटम कहाँ रहता है: बीच में (center), जहाँ दोनों ओर आइटम होते हैं, या भीतरी शुरुआती किनारे (start) पर, जहाँ आइटम सिर्फ़ उसके बाद होते हैं। |
itemWidth |
डिज़ाइन सिस्टम का | हीरो की चौड़ाई। तय चौड़ाइयों के साथ, हर आइटम की चौड़ाई। |
fluidWidth |
true |
true हीरो के बग़ल के आइटम को एक मध्यम और एक छोटी चौड़ाई तक सँकरा करता है, और हर चौड़ाई स्क्रॉल के साथ चलती है। false हर आइटम को हीरो जितना चौड़ा बनाता है, और दिखने वाला आख़िरी आइटम किनारे पर कट जाता है। |
contentAlignment |
center |
फ़्लुइड चौड़ाइयों के साथ, सँकरे आइटम के कॉन्टेंट का कौन-सा हिस्सा दिखता है: उसका बीच का हिस्सा, या हीरो के सबसे पास वाला हिस्सा (toward-hero)। |
scaleOthers |
false |
हीरो के अलावा बाक़ी आइटम को स्क्रॉल के साथ छोटा बनाता है, फ़्लुइड या तय चौड़ाइयों के साथ। आइटम के बीच का गैप वही रहता है: तय चौड़ाइयों के साथ छोटे आइटम अपने पड़ोसियों के पास खिसक आते हैं। |
snap |
true |
स्क्रॉल ख़त्म होने पर पंक्ति पूरे आइटम पर ठहरती है, या जहाँ स्क्रॉल ख़त्म हो वहीं रहती है। |
loop |
false |
पंक्ति को अंतहीन बनाता है: आख़िरी आइटम के बाद पहला आता है। सिर्फ़ दो या ज़्यादा आइटम के साथ। |
वेब पर fluidWidth का नाम fixed-width है और snap का free-scroll, क्योंकि ये उन प्रॉपर्टी के उलटे हैं जिनका डिफ़ॉल्ट true है।
कुछ आम पंक्तियाँ:
| किसके लिए | क्या सेट करें |
|---|---|
| कई आइटम ब्राउज़ करना: एल्बम, जगहें | कुछ नहीं: डिफ़ॉल्ट ही। |
| एक बार में एक फ़ीचर्ड आइटम, अगले की झलक के साथ | ऐसा itemWidth जो कम से कम कैरसेल जितना चौड़ा हो। हीरो उतना चौड़ा हो जाता है जितना वह हो सकता है। |
| फ़ीचर्ड पंक्ति, जिसके दोनों ओर आइटम हों | और कुछ नहीं: हीरो डिफ़ॉल्ट रूप से बीच में होता है। अक्सर loop के साथ, ताकि दोनों ओर हमेशा भरी रहें। |
| किनारे से शुरू होने वाली पंक्ति, जिसमें हीरो सबसे पहले हो | heroAlignment start। |
| सादी स्क्रॉल होने वाली पंक्ति, जैसे हाल में देखे गए आइटम | heroAlignment start, fluidWidth false और snap false। |
itemWidth अपने कॉन्टेंट के आकार के हिसाब से चुनें: चौकोर कवर, लंबे पोस्टर और चौड़े थंबनेल को अलग-अलग चौड़ाइयाँ चाहिए, एक ही प्रॉडक्ट में भी। फ़्लुइड चौड़ाइयों के साथ हीरो बाक़ी आइटम के लिए जगह छोड़ता है: जहाँ आगे आइटम हैं, वहाँ वह कभी उस चौड़ाई से ज़्यादा नहीं बढ़ता जो हर ओर एक छोटा आइटम छोड़ती है, और कभी उस चौड़ाई से कम नहीं सिकुड़ता जो अगले आइटम को उससे ज़्यादा चौड़ा न होने दे। जो पंक्ति इसके लिए बहुत सँकरी हो, उसमें कैरसेल एक बार में एक आइटम दिखाता है, पंक्ति जितना चौड़ा।
दो चीज़ें पिछले संशोधन से अलग हैं। जब तक बाक़ी प्लैटफ़ॉर्म बराबरी पर नहीं आते, यह वेब का व्यवहार है।
heroAlignmentका डिफ़ॉल्ट अबcenterहै। पहले यहstartथा। दोनों मान बने हुए हैं।- पड़ोसी आइटम स्क्रॉल की हर स्थिति में एक गैप की दूरी पर रहते हैं, सिर्फ़ ठहरी हुई अवस्था में नहीं। पहले, जब कोई आइटम पंक्ति के किनारे से गुज़रता था तो गैप बढ़ जाता था, और स्केल किया हुआ आइटम अपने चारों ओर अतिरिक्त जगह छोड़ता था।
| आपके पास यह था | अब |
|---|---|
कोई heroAlignment नहीं |
हीरो बीच में है, और हर ओर एक सँकरा आइटम है। पंक्ति को पहले जैसा रखने के लिए heroAlignment को start सेट करें (वेब पर hero-alignment="start")। |
heroAlignment start |
कुछ बदलना नहीं है। |
heroAlignment center |
कुछ बदलना नहीं है। आप प्रॉपर्टी हटा सकते हैं। |
तय चौड़ाइयों के साथ scaleOthers |
छोटे आइटम अब अपने पड़ोसियों से एक गैप की दूरी पर रहते हैं, पहले से ज़्यादा पास। कुछ बदलना नहीं है। |
पंक्ति से ज़्यादा चौड़ा itemWidth, कोई heroAlignment नहीं |
हीरो पहले से सँकरा है, क्योंकि हर ओर एक छोटा आइटम रहता है। सबसे चौड़े हीरो के लिए heroAlignment को start सेट करें। |
फ़्लुइड चौड़ाइयों के साथ आइटम अब किनारे पर शून्य से पंक्ति में प्रवेश करता है और भीतर आते-आते बढ़ता है, पूरी चौड़ाई के साथ सरककर नहीं आता। ठहरी हुई अवस्था में पंक्ति पहले जैसी दिखती है।
पिछले संशोधन की layout प्रॉपर्टी हटा दी गई है। उसका हर मान अब ऊपर की प्रॉपर्टी का एक मेल है:
पिछला layout |
अब |
|---|---|
| डिफ़ॉल्ट पर छोड़ा हुआ | heroAlignment start। जो पंक्ति फ़ोन से ज़्यादा चौड़ी नहीं है, उसमें तस्वीर वही रहती है। ज़्यादा चौड़ी पंक्ति में हीरो अपनी सीमा तक बढ़ता है। |
hero |
heroAlignment start और ऐसा itemWidth जो कम से कम कैरसेल जितना चौड़ा हो, ताकि हीरो उतना चौड़ा हो जाए जितना वह हो सकता है। तस्वीर वही रहती है। |
uncontained |
heroAlignment start, fluidWidth false और snap false (वेब पर hero-alignment="start" fixed-width free-scroll)। तस्वीर वही रहती है। |
- बिंदु।
indicatorआइटम के नीचे की एक पंक्ति में, कैरसेल के बीच में, ठहरने की हर जगह के लिए एक बिंदु बनाता है। मौजूदा बिंदु खिंचा हुआ होता है, और पंक्ति के स्क्रॉल होने के साथ यह खिंचाव एक बिंदु से अगले पर चला जाता है। सारे बिंदु मिलकर एक कंट्रोल हैं: पंक्ति को चलाने के लिए उन पर कहीं भी दबाएँ या ड्रैग करें। इन्हें छोटी फ़ीचर्ड पंक्ति के लिए इस्तेमाल करें। अगर बिंदु इतने ज़्यादा हों कि प्लेबैक कंट्रोल के बग़ल में न समाएँ, तो वे नहीं दिखाए जाते, और डीबग बिल्ड यह बताते हैं। - ऑटोप्ले।
autoplayपंक्ति को हरautoplayIntervalमिलीसेकंड पर (डिफ़ॉल्ट सिस्टम में 5 सेकंड) एक आइटम आगे बढ़ाता है। ज़्यादा टेक्स्ट वाले आइटम को इमेज से ज़्यादा समय दें।loopके बिना, वह आख़िरी आइटम के बाद पहले आइटम पर लौट जाता है। वह कभी फ़ोकस नहीं ले जाता और कुछ पढ़कर नहीं सुनाता। - ठहराव। ऑटोप्ले तब तक ठहरा रहता है जब तक पॉइंटर कैरसेल के ऊपर है, जब तक फ़ोकस उसमें कहीं भी है, जब तक वह दबाया या ड्रैग किया जा रहा है, और जब तक विंडो छिपी हुई है। आख़िरी ठहराव ख़त्म होने पर वह वहीं से आगे चलता है जहाँ रुका था; जब व्यक्ति पंक्ति को ख़ुद चलाता है, तो उसके बाद अंतराल फिर से शुरू होता है।
- कम मोशन। जहाँ प्लैटफ़ॉर्म की “मोशन कम करें” सेटिंग चालू है, वहाँ ऑटोप्ले कभी नहीं चलता, और प्लेबैक कंट्रोल और प्रगति नहीं दिखाए जाते। चौड़ाइयाँ, स्केल और बिंदु तब भी व्यक्ति के अपने स्क्रॉल के साथ चलते हैं।
- प्लेबैक कंट्रोल। जब तक ऑटोप्ले चालू है, बिंदुओं की पंक्ति के अंत में एक गोल बटन उसे रोकता और चलाता है, और
pauseयाplay_arrowदिखाता है। उसका नामpauseLabelयाplayLabelसे आता है, इस हिसाब से कि वह क्या करने वाला है। वहpausedबदलता है औरpausedChangeएमिट करता है (वेब परpausedchange); आपका कोड भीpausedसेट कर सकता है, जिससे कुछ एमिट नहीं होता। - प्रगति।
autoplayProgressके साथ, मौजूदा बिंदु अगले आइटम तक का समय बीतने के साथ भरता जाता है।
प्लेबैक को कंट्रोल करने लायक़ रखें। प्रॉडक्ट playbackControl को false करके प्लेबैक कंट्रोल छिपा सकता है, पर जहाँ भी हो सके उसे बनाए रखना चाहिए। ठहराव मोशन रोकने का तरीक़ा नहीं हैं: टच में होवर नहीं होता, उँगली पंक्ति को तभी तक थामती है जब तक वह वहाँ टिकी है, और जो स्क्रीन रीडर फ़ोकस ले जाए बिना पढ़ता है वह उसे बिल्कुल नहीं थामता। कंट्रोल के बिना, फ़ोन पर कोई व्यक्ति ऑटोप्ले वाले कैरसेल को सिर्फ़ सिस्टम की “मोशन कम करें” सेटिंग से रोक सकता है। इसे सिर्फ़ वहाँ छिपाएँ जहाँ आपका प्रॉडक्ट मोशन रोकने का कोई और तरीक़ा देता है, जैसे पेज के सारे चलते कॉन्टेंट के लिए एक पॉज़ (WCAG 2.2.2)।
जिस पंक्ति में स्क्रॉल बार नहीं होता, उसमें माउस के पास पंक्ति को हिलाने वाला कोई एक दबाव नहीं होता: बस Shift के साथ व्हील, या बिंदु, जहाँ वे बने हों। इसलिए कैरसेल अपनी पंक्ति के दोनों सिरों के ऊपर एक पिछला और एक अगला कंट्रोल बनाता है। ये शेवरॉन वाले सिर्फ़-आइकन Button हैं, उस वैरिएंट में जो डिज़ाइन सिस्टम तय करता है (डिफ़ॉल्ट सिस्टम में elevated), और हर एक, बिंदुओं और ऐरो कुंजियों की तरह, पंक्ति को एक आइटम पीछे या आगे ले जाता है।
navigation |
कहाँ बनते हैं | कब दिखते हैं |
|---|---|---|
auto (डिफ़ॉल्ट) |
जहाँ मुख्य पॉइंटर ऐसा माउस या ट्रैकपैड है जो होवर कर सकता है | जब तक पॉइंटर कैरसेल के ऊपर है या फ़ोकस उसके भीतर है |
always |
हर डिवाइस पर, टच समेत | हमेशा |
none |
कभी नहीं | कभी नहीं |
- डिफ़ॉल्ट रूप से टच पर क्यों नहीं। उँगली पंक्ति को स्वाइप कर लेती है, और फ़ोन पर ये कंट्रोल हमेशा आइटम के ऊपर खड़े रहते। जहाँ आपके लोगों को टच पर भी इनकी ज़रूरत हो, वहाँ
alwaysचुनें। - सिरों पर।
loopके बिना, पहले आइटम पर पिछला कंट्रोल और आख़िरी पर अगला कंट्रोल डिसेबल हो जाता है। डिसेबल कंट्रोल फ़ोकस और Tab क्रम में अपनी जगह बनाए रखता है, इसलिए अगला बार-बार दबाने से फ़ोकस कभी नहीं छूटता।loopके साथ वे घूमकर आगे बढ़ते हैं। - दबाव जुड़ते जाते हैं। पंक्ति चलते समय किया गया दबाव वहाँ से गिना जाता है जहाँ वह जा रही है, इसलिए दो तेज़ दबाव दो आइटम आगे ले जाते हैं।
- ऑटोप्ले। दबाव व्यक्ति की अपनी चाल है: पंक्ति के ठहरने के बाद अंतराल फिर से शुरू होता है। जब तक पॉइंटर कंट्रोल के ऊपर है या फ़ोकस उन पर है, ऑटोप्ले ठहरा रहता है, जैसे कैरसेल में कहीं और।
- नाम।
previousLabelऔरnextLabelउन्हें सहायक तकनीक के लिए नाम देते हैं, जैसे “पिछली सैर” और “अगली सैर”। कोई नाम न हो तो डीबग बिल्ड रिपोर्ट करते हैं।
जहाँ तक हो सके auto रखें। none तभी चुनें जब आपका पेज माउस को पंक्ति हिलाने का कोई और तरीक़ा दे, जैसे बिंदु।
- कॉन्टेंट हीरो की चौड़ाई पर लेआउट होता है। हर आइटम अपना कॉन्टेंट हीरो की चौड़ाई पर लेआउट करता है, इसलिए सँकरा आइटम अपनी इमेज का बीच का हिस्सा दिखाता है, या
contentAlignmenttoward-hero के साथ हीरो के सबसे पास वाला हिस्सा, और आइटम के बढ़ने-सिकुड़ने के साथ इमेज उसके भीतर सरकती है। ऐसी इमेज दें जो दिखने वाले हिस्से से भी ठीक समझ आए। - आइटम पर कोई टेक्स्ट नहीं। आइटम कोई कैप्शन नहीं बनाता, क्योंकि इमेज के ऊपर के टेक्स्ट के लिए किसी कंट्रास्ट की गारंटी नहीं दी जा सकती। कैप्शन अपने कॉन्टेंट में अपने ही स्क्रिम के ऊपर रखें, या उसे कैरसेल के बाहर दिखाएँ।
- हर आइटम में एक क्रिया। आइटम वह चीज़ खोलता है जो वह दिखाता है। बटन, लिंक और दूसरे कंट्रोल उसके कॉन्टेंट से बाहर रखें।
- कोई अक्षम आइटम नहीं। ब्राउज़ की जाने वाली पंक्ति में ऐसा कुछ नहीं होता जो दिखे पर उपलब्ध न हो। ऐसे आइटम को छोड़ दें।
- ख़ाली आइटम भी दिखते हैं। आइटम का कंटेनर अपने कॉन्टेंट के नीचे अपनी सामान्य अवस्था के रंग से भरा रहता है, आइटम का स्टेट चाहे जो हो, इसलिए जिस आइटम की इमेज अभी लोड नहीं हुई है वह भी दिखता है।
- स्टेट कॉन्टेंट के ऊपर दिखते हैं। होवर, फ़ोकस और दबाना कॉन्टेंट के ऊपर एक लेयर के रूप में बनते हैं, और रिपल उसी लेयर में होता है, इसलिए वे किसी भी इमेज पर दिखते हैं।
लोग पंक्ति को टच, पेन, ट्रैकपैड, आड़े व्हील, या Shift के साथ खड़े व्हील से स्क्रॉल करते हैं। snap के साथ, स्क्रॉल ख़त्म होने पर पंक्ति पूरे आइटम पर ठहरती है: फ़्लिंग अपनी दिशा के अगले आइटम पर ले जाता है, और धीरे छोड़ने पर पंक्ति सबसे पास वाले आइटम पर जाती है। फ़्लिंग वह छोड़ना है जो प्लैटफ़ॉर्म के न्यूनतम फ़्लिंग वेग से तेज़ हो, या जहाँ प्लैटफ़ॉर्म कोई वेग नहीं बताता वहाँ 0.5 पॉइंट प्रति मिलीसेकंड से। loop के बिना, सीमा के अंत पर आख़िरी आइटम हीरो होता है, और उसके बाद की जगहें ख़ाली रहती हैं। loop के साथ, हर आइटम एक बार बनता है, हीरो के इर्द-गिर्द जिस जगह वह पड़े वहाँ, और पंक्ति बिना अंत के घूमती रहती है। जहाँ मोशन कम किया गया है, वहाँ कैरसेल की अपनी शुरू की हुई हर गति तुरंत हो जाती है। माउस से, पिछला और अगला कंट्रोल पंक्ति को एक-एक आइटम आगे-पीछे करते हैं।
जब कैरसेल की चौड़ाई या उसके आइटम बदलते हैं, तो वह अपनी जगहें फिर से सजाता है और जो आइटम मुख्य था उसे बिना मोशन के वहीं रखता है जहाँ वह था।
- हर आइटम को ऐसा लेबल दें जो बताए कि उसका कॉन्टेंट क्या दिखाता है, अपने प्रॉडक्ट की भाषा में।
itemWidthकॉन्टेंट के आकार के अनुसार चुनें।- कैरसेल को ऐसा
labelदें जो पंक्ति का नाम बताए, जैसे “हाल में चलाए गए”। - जब भी कैरसेल अपने आप आगे बढ़ता हो, प्लेबैक कंट्रोल बनाए रखें, और उसे
playLabelऔरpauseLabelदें।
- आइटम के कॉन्टेंट के भीतर कंट्रोल न रखें। आइटम पहले से एक बटन है।
- कैरसेल को ऐसे कॉन्टेंट के लिए इस्तेमाल न करें जिसे लोगों को पूरा देखना ज़रूरी हो, जैसे चरण या शर्तें। जो आइटम नहीं दिख रहे, वे आसानी से छूट जाते हैं।
- ब्राउज़ की जाने वाली लंबी पंक्ति के लिए ऑटोप्ले चालू न करें। वह बिंदुओं वाली छोटी फ़ीचर्ड पंक्ति के अनुकूल है।
- प्लेबैक कंट्रोल तब तक न छिपाएँ जब तक आपका प्रॉडक्ट मोशन रोकने का कोई और तरीक़ा न देता हो।
- रोल
list- लेबलिंग
- The items are a list named by label. Each item is one button named by its label, with its position and the number of items; its content is not read. The indicator is one slider named by label, whose value text is the current item's label. The playback control is a button named by pauseLabel while playing and by playLabel while paused. Items out of view are still reachable, and focusing one scrolls it into place. The previous and next controls are buttons named by previousLabel and nextLabel, disabled at the ends of a row that does not loop.
- न्यूनतम टार्गेट
- दिखने वाला आकार छोटा होने पर भी हिट एरिया न्यूनतम टार्गेट साइज़ को पूरा करता है। minimum 32px · pointer 44px · spacing 8px · touch 48px
कीबोर्ड
| कुंजियाँ | क्रिया |
|---|---|
| Tab / Shift+Tab | Moves through the carousel's stops: the playback control (while it is drawn), the previous and next controls (while they are drawn), then the items as one stop (the item that last had focus, or else the resting item), then the indicator (while it is drawn), and on out (CRL-17). |
| Right Arrow / Left Arrow | On an item: moves focus to the next or previous item and brings it into place. On the indicator: moves the row to the next or previous position. Both wrap only while the carousel loops, and are mirrored in right-to-left layouts. |
| Home / End | On an item: moves focus to the first or last item and brings it into place. On the indicator: moves the row to the first or last position. |
| Enter / Space | On an item: activates it (its click). On the playback control: pauses or plays autoplay. On the previous or the next control: moves the row back or on by one position (CRL-43). |
टिप्पणियाँ
- Scrolling is never the only way to reach an item (WCAG 2.5.7, 2.1.1): the previous and next controls move the row one position with a single press of a mouse — drawn by default wherever the primary pointer is fine and can hover —, and the arrow keys, the indicator and screen-reader focus move through every item and bring it into place. The row draws no scroll bar, so without the controls a mouse could move the row only with Shift and the wheel.
- Where the previous and next controls are, and when. They stand over the ends of the row, as the arrows of Ant Design's and Mantine's carousels and the overlay layouts of Fluent 2's do, not in the controls row, which exists only for a featured row with dots or autoplay. By default (auto) they are drawn only for a pointer that is fine and can hover, and shown while it is over the carousel or focus is within it: a touch screen moves the row with the finger's own swipe, and there the controls would stand over the items for good. A product whose people need them on touch as well sets always. Their place in the Tab sequence is the WAI-ARIA carousel example's: the playback control, then previous and next, then the slides.
- A previous or next control at the end of a row that does not loop is disabled but keeps focus and its place in the Tab order (the Button's focusableWhenDisabled), so that pressing next again and again never drops focus to the page, and the number of stops does not change with the scroll.
- An item entering or leaving at an edge of a row with fluid widths is, between resting positions, narrower than a touch target (CRL-4, CRL-12). A row that snaps never rests there; a row that does not snap can, and the arrow keys, the indicator and a further scroll all bring that item to a slot, where it has its whole target.
- Autoplay (WCAG 2.2.2 Pause, Stop, Hide). A carousel that advances by itself holds while it is hovered, while focus is anywhere in it, while it is pressed and while it is hidden, and it never advances where the platform's reduced-motion setting is on (CRL-33, CRL-34). While autoplay is on, the playback control is drawn by default and is the first Tab stop, so a keyboard user reaches it before the items (CRL-17).
- Keep playback controllable. A product may hide the playback control (playbackControl false), but it should keep it wherever it can. The holds are not a way to stop the motion: on touch there is no hover, a finger on the carousel holds it only while it stays there, and a screen reader that reads without moving focus does not hold it at all. Without the control, a person on a phone can stop an autoplaying carousel only through the system's reduced-motion setting. Hide it only where the product gives the person another way to stop the motion, such as a pause for all moving content on the page.
- Autoplay makes no announcement and never moves focus (CRL-32). A person who wants to know what changed finds the current item as the indicator's value.
- Loop keeps the arrow keys and the indicator going round, but Home and End still go to the first and last item, so a person can always find the ends of an endless row.
- The indicator is one slider, not a row of unlabelled buttons: one Tab stop, the arrow keys to move, the current item's label as its value. Its hit area is the whole container and the controls row's height, so the dots need no target of their own.
- The current dot is told apart by its stretched shape, not by color alone (WCAG 1.4.1), and the other dots use the functional outline role (3:1 against the surface).
- Web: the host has no role; a shadow element with role list, named by label, holds the item slot, so the slotted `<tanrei-carousel-item>` elements (role listitem, around a shadow element with role button and tabindex, roving: 0 on the Tab stop, -1 on the others) are its items, as the interactive card draws its button. The indicator is a shadow element with role slider and tabindex 0, and the playback control a native `<button>`; both sit after the list, outside it. Compose has no list role: the row gives `collectionInfo` and each item `collectionItemInfo` with `Role.Button`; the indicator is a `progressBarRangeInfo` with `setProgress`. Flutter reads each item's position through `IndexedSemantics`, and the indicator is a `Semantics(slider: true)` with increase and decrease actions. SwiftUI's indicator is `accessibilityAdjustableAction`, React Native's the adjustable role with increment and decrement actions. SwiftUI and React Native have no position-in-set property for a custom container, so there the screen reader's own count of the items stands in for CRL-19's position and number; their READMEs say so.
- How a state looks is a value decision of the active design system; components read the state's tokens and never compute the effect themselves.
इससे जनरेट किया गया: specs/carousel.spec.json, tokens/sys/measure.tokens.json
- कैरसेल एक लिस्ट है जिसका नाम
labelसे आता है। हर आइटम एक बटन है जिसका नाम उसके लेबल से आता है, आइटम के बीच उसकी जगह और उनकी संख्या के साथ। उसका कॉन्टेंट सहायक तकनीक से छिपा रहता है। - जो आइटम नहीं दिख रहे, वे भी क्रम से उपलब्ध रहते हैं, इसलिए स्क्रीन रीडर हर एक तक पहुँचता है। स्क्रीन रीडर का फ़ोकस किसी आइटम पर ले जाने से वह स्क्रॉल होकर अपनी जगह आ जाता है।
- Tab स्टॉप। कैरसेल में ज़्यादा से ज़्यादा पाँच होते हैं: प्लेबैक कंट्रोल, जब तक वह बना हुआ है; पिछला और अगला कंट्रोल, जब तक वे बने हुए हैं; आइटम, एक स्टॉप के रूप में; और बिंदु, जब तक वे बने हुए हैं। प्लेबैक कंट्रोल सबसे पहले आता है, आइटम से पहले, ताकि कीबोर्ड इस्तेमाल करने वाला व्यक्ति किसी और चीज़ तक पहुँचने से पहले मोशन रोक सके। पिछला और अगला कंट्रोल आइटम से पहले आते हैं, जैसे WAI-ARIA के कैरसेल उदाहरण में। आइटम में प्रवेश उस आइटम पर होता है जिस पर पिछली बार कीबोर्ड फ़ोकस था, नहीं तो उस आइटम पर जो हीरो की जगह ठहरा हुआ है।
- Right Arrow और Left Arrow फ़ोकस को अगले और पिछले आइटम पर ले जाती हैं। वे सिरों पर रुक जाती हैं, और सिर्फ़ तब घूमकर दूसरे सिरे पर पहुँचती हैं जब कैरसेल लूप करता है। Home और End पहले और आख़िरी आइटम पर ले जाती हैं, लूप करने वाली पंक्ति में भी। दाएँ से बाएँ वाले लेआउट में Left Arrow अगले आइटम पर ले जाती है।
- फ़ोकस ले जाने से फ़ोकस वाला आइटम हीरो की जगह आ जाता है, उतना पास जितना सीमा का अंत आने दे, और लूप करने वाली पंक्ति में छोटे रास्ते से। जिस पंक्ति में तय चौड़ाइयाँ हैं और जो शुरुआती किनारे से खुलकर स्क्रॉल होती है, उसमें वह आइटम को बस पूरा दिखने लायक़ ले आता है।
- Enter और Space फ़ोकस वाले आइटम को सक्रिय करती हैं। दबाने की जो क्रिया स्क्रॉल में बदल जाए, वह उस आइटम को सक्रिय नहीं करती जिस पर वह शुरू हुई थी।
- बिंदु मिलकर एक स्लाइडर हैं जिसका नाम
labelसे आता है और जिसका मान मौजूदा आइटम का लेबल है। ऐरो कुंजियाँ, Home और End, और प्लैटफ़ॉर्म की बढ़ाने और घटाने की क्रियाएँ पंक्ति को एक जगह आगे-पीछे करती हैं। मौजूदा बिंदु अपने खिंचे हुए शेप से पहचाना जाता है, सिर्फ़ रंग से नहीं। - प्लेबैक कंट्रोल एक बटन है जिसका नाम चलते समय
pauseLabelऔर रुके होने परplayLabelसे आता है। उसका कोई दबाया हुआ स्टेट नहीं है, इसलिए वह कभी “रोकें, दबाया हुआ” नहीं पढ़ा जाता। उसे सक्रिय करने पर फ़ोकस उसी पर रहता है। उसके रोकने और चलाने के ग्लिफ़ मिरर नहीं होते, और आइकन फ़ॉन्ट के लोड होने से पहले किसी ग्लिफ़ का नाम टेक्स्ट के रूप में नहीं बनता। - पिछला और अगला कंट्रोल बटन हैं जिनके नाम
previousLabelऔरnextLabelसे आते हैं। किसी को सक्रिय करने पर फ़ोकस उसी पर रहता है। जो पंक्ति लूप नहीं होती, उसके सिरों पर कंट्रोल डिसेबल होता है, पर फ़ोकस बनाए रखता है और Tab क्रम में रहता है।autoमें छिपे होने पर भी वे Tab से पहुँचे जाते हैं और स्क्रीन रीडर उन्हें पढ़ता है, और फ़ोकस आने पर वे दिखते हैं। दाएँ-से-बाएँ लेआउट में पिछला कंट्रोल दाईं ओर होता है, और जहाँ आइकन सेट कहता है वहाँ शेवरॉन उलटे बनते हैं। - ऑटोप्ले तब तक ठहरा रहता है जब तक फ़ोकस कैरसेल में कहीं भी है, वह कभी फ़ोकस नहीं ले जाता और कुछ पढ़कर नहीं सुनाता, और जहाँ मोशन कम किया गया है वहाँ कभी नहीं चलता।
- फ़ोकस रिंग आइटम के भीतर बनती है, जहाँ पंक्ति उसे काट नहीं सकती, और बिंदुओं और प्लेबैक कंट्रोल के चारों ओर। वह सिर्फ़ कीबोर्ड फ़ोकस के लिए दिखती है।
- हर आइटम का हिट एरिया उसका कंटेनर और हर ओर का आधा गैप है, और कभी न्यूनतम टार्गेट से कम नहीं होता, छोटे आइटम के लिए भी। जो आइटम किनारे पर अभी प्रवेश कर रहा है या निकल रहा है, वह उससे सँकरा होता है, और उसका हिट एरिया कभी अपने पड़ोसी के हिट एरिया को नहीं ढकता। प्लेबैक कंट्रोल का हिट एरिया टच टार्गेट है, और बिंदुओं का हिट एरिया उनका पूरा कंटेनर और पंक्ति की ऊँचाई है।
- स्क्रॉल करना कभी किसी आइटम तक पहुँचने का अकेला तरीक़ा नहीं होता: पिछला और अगला कंट्रोल माउस के एक दबाव से पंक्ति को हिलाते हैं (WCAG 2.5.7), और ऐरो कुंजियाँ, बिंदु और स्क्रीन रीडर का फ़ोकस हर एक तक पहुँचते हैं।
- बड़े टेक्स्ट साइज़ पर कैरसेल अपनी ऊँचाई और अपने आइटम बनाए रखता है। उसमें अपना कोई टेक्स्ट नहीं होता, और आपका कॉन्टेंट टेक्स्ट साइज़ के साथ ख़ुद चलता है।
- डीबग बिल्ड इनकी रिपोर्ट करते हैं: बिना लेबल का आइटम, बिना
labelका कैरसेल, बिनाplayLabelयाpauseLabelका प्लेबैक कंट्रोल, बिनाpreviousLabelयाnextLabelके पिछला और अगला कंट्रोल, बिंदु जो समाते नहीं, अनजानheroAlignment,contentAlignmentयाnavigation, और ऐसाitemWidthयाautoplayIntervalजो धनात्मक संख्या नहीं है। वेब आइटम के कॉन्टेंट के भीतर के इंटरैक्टिव एलिमेंट की भी रिपोर्ट करता है।
प्लैटफ़ॉर्म की ज्ञात कमियाँ:
- SwiftUI और React Native में कस्टम कंटेनर के लिए सेट के भीतर की जगह बताने वाली कोई प्रॉपर्टी नहीं है, इसलिए हर आइटम की जगह और आइटम की संख्या के बदले स्क्रीन रीडर की अपनी गिनती काम आती है। SwiftUI में लिस्ट का रोल भी नहीं है: कैरसेल एक कंटेनर है जिसका नाम
labelसे आता है। - Compose में लिस्ट का रोल नहीं है। पंक्ति अपने कलेक्शन का साइज़ देती है और हर आइटम अपनी जगह, बटन के रोल के साथ, इसलिए TalkBack लिस्ट की जगह कलेक्शन पढ़कर सुनाता है।
- आइटम के कॉन्टेंट को सिर्फ़ वेब जाँच सकता है, इसलिए उसके भीतर के कंट्रोल की रिपोर्ट सिर्फ़ वेब करता है। बाक़ी प्लैटफ़ॉर्म पर यह नियम निभाना आपका काम है।
- Web: Tab स्टॉप हर उस आइटम पर चला जाता है जो फ़ोकस लेता है, क्लिक से मिला फ़ोकस भी, जबकि स्पेक के अनुसार यह वह आइटम है जिस पर पिछली बार कीबोर्ड फ़ोकस था। पेन का फ़्लिक सबसे पास वाले आइटम पर ठहरता है, अगले पर नहीं। स्क्रीन रीडर का जो वर्चुअल कर्सर फ़ोकस नहीं ले जाता, वह पंक्ति को वैसे स्क्रॉल करता है जैसे ब्राउज़र करता है, और आइटम को हीरो की जगह नहीं लाता।
- SwiftUI: कैरसेल हमेशा अपने हाइट टोकन जितना ऊँचा होता है, क्योंकि SwiftUI किसी फ़्रेम को स्टैक के प्रस्ताव से अलग नहीं पहचान सकता। उसका साइज़ किसी लेयर के टोकन से तय करें। ठहरने की गति स्क्रॉल व्यू के अपने धीमे पड़ने के साथ चलती है, कैरसेल के स्क्रॉल मोशन के साथ नहीं, और जहाँ मोशन कम किया गया है वहाँ तुरंत नहीं होती। वह हर आइटम बनाता है और स्क्रॉल के हर फ़्रेम पर हर एक को फिर से रखता है। ऐरो कुंजियाँ, Tab स्टॉप और VoiceOver का फ़ोकस नियमों के रूप में जाँचे गए हैं, किसी डिवाइस पर कीबोर्ड या VoiceOver के साथ नहीं।
- Compose हर आइटम को कंपोज़ और लेआउट करता है, उन्हें भी जो नहीं दिख रहे। व्हील, जो फ़्लिंग नहीं करता, सबसे पास वाले आइटम पर ठहरता है। स्क्रॉल सिर्फ़ Robolectric में जाँचा गया है, किसी डिवाइस पर नहीं।
- Flutter स्नैप करने वाले कैरसेल को माउस व्हील के हर इवेंट के बाद ठहराता है, व्हील का जेस्चर ख़त्म होने पर नहीं। इसे अभी किसी डिवाइस पर TalkBack और VoiceOver के साथ नहीं जाँचा गया है।
- React Native स्क्रॉल के हर फ़्रेम पर हर आइटम को JavaScript थ्रेड पर फिर से लेआउट करता है, और हर आइटम रेंडर करता है। ऐरो कुंजियाँ सिर्फ़ वहाँ काम करती हैं जहाँ हार्डवेयर कीबोर्ड के इवेंट ऐप तक पहुँचते हैं। स्क्रॉल के अनुसार आइटम का रखा जाना, ठहरना, दाएँ से बाएँ और स्क्रीन रीडर का फ़ोकस सिर्फ़ Jest में जाँचे गए हैं, किसी डिवाइस पर कभी नहीं।
m3-likeमें आइटम जान-बूझकर डिफ़ॉल्ट फ़िल रखते हैं, जहाँ Material का कैरसेल सरफ़ेस का रंग इस्तेमाल करता है, ताकि जिस आइटम की इमेज लोड नहीं हुई है वह भी दिखे।
- कैरसेल को
labelदें, और हर आइटम को ऐसा लेबल जो बताए कि उसका कॉन्टेंट क्या दिखाता है। कॉन्टेंट पढ़ा नहीं जाता। - ऑटोप्ले के साथ, प्लेबैक कंट्रोल को ऐसे
playLabelऔरpauseLabelदें जो बताएँ कि वह क्या करता है, और उसे बना रहने दें। - पिछले और अगले कंट्रोल को
previousLabelऔरnextLabelदें, औरnavigationकोautoपर रखें, जब तक आपका पेज माउस को पंक्ति हिलाने का कोई और तरीक़ा न दे। - कंट्रोल आइटम के कॉन्टेंट से बाहर रखें।
- अगर कॉन्टेंट में ऐसा अर्थ है जो उसके लेबल में नहीं है, जैसे किसी पोस्टर पर क़ीमत, तो उसे लेबल में रखें।
- SwiftUI, Compose और React Native पर आइटम की संख्या सीमित रखें: वहाँ कैरसेल हर आइटम बनाता है, उन्हें भी जो नहीं दिख रहे।