التخطّي إلى المحتوى
menumenu tanreiexpand_morecontrasttranslate
tanreiexpand_more
البدءWebReactSwiftUIJetpack ComposeFlutterReact Nativeالإعدادات الجاهزةنظام التصميم الخاص بكاستخدام Tanrei مع وكلاء الذكاء الاصطناعيالعلامة التجاريةرموز التصميمأنظمة التصميم والتخصيصTheme Studioاللونالطباعةالأيقوناتالشكلالارتفاعالحركةحالات التفاعلالسلوكالتخطيطإمكانية الوصولالكلماترموز الألوانرموز السلّم الطباعيرموز الشكلرموز الارتفاعرموز الحركةرموز الحالةرموز التباعد والقياسالمكوّناتالزرزر الإجراء الرئيسيالزر المقسَّممجموعة الأزرارزر مع قائمةشريط الأدواتزر النسخخانة الاختيارزر الاختيارمفتاح التبديلالرقاقةقائمة الخياراتشريط التمريرحقل شريط التمريرالتقويمDateTimePickerمجموعة الحقولمجموعة أزرار الاختيارمجموعة خانات الاختيارعنصر الاختيارحقل الاختيارشريط القوائمرفع الملفاتمنتقي الملفات متقدّمساحة الإفلاتحقل إدخال النص متقدّمحقل النصحقل الرقاقاتالحقلمربع التحرير والسرد متقدّمحقل التحرير والسردحقل إدخال العدد متقدّمحقل العددحقل إدخال اللون متقدّمحقل اللونحقل إدخال الرمز لمرة واحدة متقدّمحقل الرمز لمرة واحدةحقل إدخال النص المدمج متقدّممربع كتابة الرسائلالبطاقةالفاصلالطبقة النمطية متقدّممربع الحوارالقائمة (list)صف القائمةاللوحة السفليةاللوحة الجانبيةالعرض الدوّاركتلة الشيفرةالجدولاللوحة المنبثقةالخطواتالأكورديونقائمة الوصفالشكل التوضيحيهيكل التطبيقرأس الصفحةالعرض الشجريالخط الزمنيمعاينة الصورمقبض تغيير الحجمالإطار القابل لتغيير الحجممنطقة التمريرالشارةمؤشر التقدمالعدّادعارض الأرقام المتحرّكمؤشر التحميلشريط الإشعار (Snackbar)التلميحاختصار لوحة المفاتيحالوسمالشيفرة المضمَّنةالتنويهالصورة الرمزيةالحالة الفارغةمجموعة الوسومهيكل التحميلعنصر الملفمربع اللونالنص المتحركعلامات التبويبعرض التبويباتشريط التطبيقشريط التنقلدرج التنقلالبحثالرابطالتنقل بين الصفحاتروابط السابق والتاليمؤشر الخطواتمسار التنقلجدول المحتوياتبطاقة الرابطقائمة FABالحالةكيف يُبنى Tanreiالمساهمةالترخيص والإسناد
الرئيسيةالمكوّناتالعرض الدوّار

العرض الدوّار

صف من العناصر المرئية يُمرَّر جانبيًّا حول عنصر واحد في الصدارة، وكل عنصر يفتح ما يعرضه. والصف المميَّز قد يدور بلا نهاية، ويعرض موضعه بنقاط، ويتقدم من تلقاء نفسه.

content_copyعرض بتنسيق Markdown
الفئة
الاحتواء
الرموز
comp.carousel
المستوى
أساسي

نظرة عامة

Web
tanrei-carousel
schedule
SwiftUI
TanreiCarousel
schedule
Jetpack Compose
TanreiCarousel
schedule
Flutter
TanreiCarousel
schedule
React Native
Carousel
schedule

مولَّد من docs/status/status.json, specs/carousel.spec.json

مواصفة معدَّلة لم تصل بعد إلى كل المنصات

تصف هذه الصفحة العرض الدوّار كما هو في المواصفة الآن. تحل اختيارات مستقلة (موضع العنصر البارز، عروض مرنة أو ثابتة، التصغير، الاستقرار على عنصر كامل، الدوران) محل الخاصية layout، ويستطيع الصف المميَّز أن يعرض نقاطًا وأن يتقدم من تلقاء نفسه. العنصر البارز (hero) صار الآن في الوسط افتراضيًّا، والعناصر المتجاورة تقف على بُعد فجوة واحدة عند كل موضع تمرير. مكوّن الويب يفعل ذلك كله منذ الآن، وكذلك العروض التوضيحية. أما SwiftUI و Compose و Flutter و React Native فموسومة أعلاه بأنها متأخرة: إلى أن تلحق بالمواصفة تقدّم المراجعة السابقة، وفيها layout وليس فيها دوران ولا نقاط ولا تشغيل تلقائي ولا عنصرا التحكم السابق والتالي. انظر العنصر البارز في الوسط في الوضع الافتراضي و الترحيل من layout.

الوضع الافتراضي: العنصر البارز في الوسط، وبجانبه عنصر صغير

landscapelocation_cityforestwaterterrainkayaking

الاستخدام

للعرض الدوّار نوع واحد من العناصر، هو item. تأخذ كل منصة العناصر بالطريقة التي تأخذ بها أي عناصر فرعية متكررة: عناصر فرعية <tanrei-carousel-item> على الويب، وعروض TanreiCarouselItem في view builder على SwiftUI، واستدعاءات TanreiCarouselItem من lambda العنصر على Compose، وعناصر widget من TanreiCarouselItem في children على Flutter، وعناصر فرعية CarouselItem على React Native.

كل عنصر إجراء واحد. يحمل محتواك، وهو في الغالب صورة، ويُصدر 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

// المراجعة السابقة. lambda للعنصر، كما تأخذ عروض Material الدوّارة. و itemWidth قيمة Dp، أو null لقيمة الرمز (token).
// 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>

المواصفات

عنصر بارز بأقصى عرض مسموح له، وعروض ثابتة تُمرَّر بحرية من حافة البداية

landscapelocation_cityforestwaterlandscapelocation_cityforestwaterterrain

ترتيب الصف: عروض ثابتة، تصغير، دوران، محتوى نحو العنصر البارز

عروض ثابتة، والصف يقف حيث ينتهي التمرير: fixed-width free-scroll
landscapelocation_cityforestwaterterrain
العناصر الأخرى مرسومة أصغر، بلا نهاية: fixed-width scale-others loop
landscapelocation_cityforestwaterterrain
بلا نهاية، والجانبان ممتلئان دائمًا: loop
landscapelocation_cityforestwaterterrain
العناصر المضيَّقة تعرض الجهة الأقرب إلى العنصر البارز: item-width=“120” content-alignment=“toward-hero” loop
landscapelocation_cityforestwaterterrainkayaking

النقاط، والتشغيل التلقائي، والتقدم، والإيقاف المؤقت، وعنصر التحكم في التشغيل وحده

النقاط: indicator
landscapelocation_cityforestwaterterrainkayaking
تشغيل تلقائي مع النقاط وعنصر التحكم في التشغيل: indicator autoplay
landscapelocation_cityforestwaterterrainkayaking
النقطة الحالية تمتلئ حتى العنصر التالي: autoplay-progress
landscapelocation_cityforestwaterterrainkayaking
متوقف مؤقتًا، من الشخص أو من المنتج: paused
landscapelocation_cityforestwaterterrainkayaking
تشغيل تلقائي بلا نقاط: عنصر التحكم في التشغيل وحده
landscapelocation_cityforestwater

لا يعمل التشغيل التلقائي أبدًا حيث يكون إعداد تقليل الحركة مفعَّلًا: هناك تقف عروض التشغيل التلقائي التوضيحية ساكنة، بلا عنصر التحكم في التشغيل وبلا التقدم.

البنية

الخصائص

الخاصية النوع القيمة الافتراضية الوصف
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. يُختبر تنفيذ كل منصة مقابل هذه المعرّفات. يُعرض نص المتطلبات كما ورد في ملف المواصفة، بالإنجليزية.

المعرّف المتطلب
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.

مطابقة الأسماء بين المنصات

التكافؤ لا يعني واجهات برمجية متطابقة. تعبّر كل منصة عن العقد نفسه بأسلوبها.

المواصفة 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 #848484
--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 — #000000 · 0%
--tanrei-comp-carousel-indicator-content-color sys.color.primary #1b1b1b
--tanrei-comp-carousel-indicator-focused-container-color — #1b1b1b · 10%
--tanrei-comp-carousel-indicator-focused-content-color — #1b1b1b
--tanrei-comp-carousel-indicator-focused-state-layer-color — #1b1b1b
--tanrei-comp-carousel-indicator-hovered-container-color — #1b1b1b · 8%
--tanrei-comp-carousel-indicator-hovered-content-color — #1b1b1b
--tanrei-comp-carousel-indicator-hovered-state-layer-color — #1b1b1b
--tanrei-comp-carousel-indicator-pressed-container-color — #1b1b1b · 10%
--tanrei-comp-carousel-indicator-pressed-content-color — #1b1b1b
--tanrei-comp-carousel-indicator-pressed-state-layer-color — #1b1b1b
--tanrei-comp-carousel-indicator-state-layer-color comp.carousel.indicator.content.color #1b1b1b
--tanrei-comp-carousel-item-container-color sys.color.surface-container-highest #eeeeee
--tanrei-comp-carousel-item-content-color sys.color.on-surface #1b1b1b
--tanrei-comp-carousel-item-focused-container-color — #d9d9d9
--tanrei-comp-carousel-item-focused-content-color — #1b1b1b
--tanrei-comp-carousel-item-focused-state-layer-color — #1b1b1b
--tanrei-comp-carousel-item-hovered-container-color — #dddddd
--tanrei-comp-carousel-item-hovered-content-color — #1b1b1b
--tanrei-comp-carousel-item-hovered-state-layer-color — #1b1b1b
--tanrei-comp-carousel-item-pressed-container-color — #d9d9d9
--tanrei-comp-carousel-item-pressed-content-color — #1b1b1b
--tanrei-comp-carousel-item-pressed-state-layer-color — #1b1b1b
--tanrei-comp-carousel-item-state-layer-color comp.carousel.item.content.color #1b1b1b
--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 — #000000 · 0%
--tanrei-comp-carousel-playback-content-color sys.color.on-surface-variant #4b4b4b
--tanrei-comp-carousel-playback-focused-container-color — #4b4b4b · 10%
--tanrei-comp-carousel-playback-focused-content-color — #4b4b4b
--tanrei-comp-carousel-playback-focused-state-layer-color — #4b4b4b
--tanrei-comp-carousel-playback-hovered-container-color — #4b4b4b · 8%
--tanrei-comp-carousel-playback-hovered-content-color — #4b4b4b
--tanrei-comp-carousel-playback-hovered-state-layer-color — #4b4b4b
--tanrei-comp-carousel-playback-pressed-container-color — #4b4b4b · 10%
--tanrei-comp-carousel-playback-pressed-content-color — #4b4b4b
--tanrei-comp-carousel-playback-pressed-state-layer-color — #4b4b4b
--tanrei-comp-carousel-playback-state-layer-color comp.carousel.playback.content.color #4b4b4b
--tanrei-comp-carousel-pressed-container-shape — 12px
--tanrei-comp-carousel-pressed-opacity — 1

نماذج الاختبار

عروض مرجعية. تلتقط كل المنصات لقطة لكل نموذج بالمعرّف نفسه حتى يمكن مقارنة النتائج.

مولَّد من 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 التي كانت في المراجعة السابقة. كل قيمة من قيمها صارت الآن تركيبًا من الخصائص أعلاه:

قيمة layout السابقة الآن
متروكة على قيمتها الافتراضية الخاصية heroAlignment بالقيمة start. في صف لا يزيد عرضه على عرض هاتف تكون الصورة نفسها. وفي صف أعرض يكبر العنصر البارز حتى حدّه.
hero الخاصية heroAlignment بالقيمة start وقيمة itemWidth لا تقل عن عرض العرض الدوّار، فيأخذ العنصر البارز أقصى عرض مسموح له. الصورة نفسها.
uncontained الخاصية heroAlignment بالقيمة start، و fluidWidth بالقيمة false، و snap بالقيمة false (أي hero-alignment="start" fixed-width free-scroll على الويب). الصورة نفسها.

النقاط والتشغيل التلقائي وعنصر التحكم في التشغيل

  • النقاط. الخاصية indicator ترسم نقطة لكل موضع سكون، في صف تحت العناصر، متوسطًا العرض الدوّار. النقطة الحالية ممطوطة، وينتقل المطّ من نقطة إلى التي تليها مع تمرير الصف. والنقاط عنصر تحكم واحد: اضغط أو اسحب في أي موضع عليها لتحريك الصف. استخدمها لصف مميَّز قصير. وإن كانت أكثر من أن تتسع بجانب عنصر التحكم في التشغيل لم تُرسم، وتقول بنيات التنقيح (debug) ذلك.
  • التشغيل التلقائي. الخاصية 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 (الافتراضي) حيث المؤشر الأساسي فأرة أو لوحة لمس تستطيع التمرير فوق العناصر (hover) ما دام المؤشر فوق العرض الدوّار أو التركيز داخله
always على كل جهاز، ومنه أجهزة اللمس دائمًا
none أبدًا أبدًا
  • لماذا لا يُرسمان على أجهزة اللمس افتراضيًّا. الإصبع يسحب الصف، وعلى الهاتف كان العنصران سيبقيان فوق العناصر طوال الوقت. اختر always حيث يحتاج إليهما مستخدموك على أجهزة اللمس أيضًا.
  • عند الطرفين. من دون loop يُعطَّل عنصر التحكم السابق عند العنصر الأول والتالي عند الأخير. ويحتفظ العنصر المعطَّل بالتركيز وبموضعه في ترتيب المفتاح Tab، فلا يضيع التركيز أبدًا مهما تكرر الضغط على التالي. ومع loop يدوران.
  • الضغطات تتراكم. الضغطة في أثناء حركة الصف تُحسب من حيث يتجه، فضغطتان سريعتان تنقلان عنصرين.
  • التشغيل التلقائي. الضغطة حركة من الشخص نفسه: تبدأ الفترة من جديد حين يستقر الصف. وما دام المؤشر فوق عنصرَي التحكم أو التركيز عليهما يُعلَّق التشغيل التلقائي، كما في أي موضع آخر من العرض الدوّار.
  • الاسمان. يسمّيهما previousLabel و nextLabel للتقنيات المساعدة، مثل «النزهة السابقة» و«النزهة التالية». وتبلّغ بنيات التنقيح (debug) عن أي منهما إذا غاب.

أبقِ auto حيثما استطعت. ولا تختر none إلا حيث تعطي صفحتك الفأرة طريقة أخرى لتحريك الصف، مثل النقاط.

العناصر ومحتواها

  • المحتوى يُخطَّط بعرض العنصر البارز. يخطّط كل عنصر محتواه بعرض العنصر البارز، فالعنصر المضيَّق يعرض وسط صورته، أو الجهة الأقرب إلى العنصر البارز حين تكون contentAlignment بالقيمة toward-hero، والصورة تنساب داخل العنصر وهو يكبر ويصغر. أعطِ صورة تُقرأ جيدًا من الجزء الذي يظهر.
  • لا نص على العنصر. لا يرسم العنصر شرحًا، لأن النص فوق صورة لا يمكن أن يُلزَم بأي تباين. ضع الشرح في محتواك فوق حجاب (scrim) من عندك، أو اعرضه خارج العرض الدوّار.
  • إجراء واحد لكل عنصر. العنصر يفتح ما يعرضه. أبقِ الأزرار والروابط وسائر عناصر التحكم خارج محتواه.
  • لا عنصر معطَّل. صف التصفح ليس فيه ما يُعرض وهو غير متاح. اترك عنصرًا كهذا خارج الصف.
  • العناصر الفارغة تبقى مرئية. تُعبَّأ حاوية العنصر تحت محتواه بلون سكونها، أيًّا كانت حالة العنصر، فالعنصر الذي لم تُحمَّل صورته بعد يبقى مرئيًّا.
  • الحالات تظهر فوق المحتوى. يُرسم التحويم والتركيز والضغط طبقةً فوق المحتوى، والتموّج في الطبقة نفسها، فتظهر على أي صورة.

التمرير والاستقرار

يمرّر الناس الصف باللمس، أو بالقلم، أو بلوحة اللمس، أو بعجلة أفقية، أو بالمفتاح Shift مع عجلة رأسية. مع snap يستقر الصف على عنصر كامل حين ينتهي التمرير: الدفعة السريعة (fling) تنقل إلى العنصر التالي في اتجاهها، والإفلات الأبطأ يذهب إلى الأقرب. والدفعة السريعة إفلات أسرع من أدنى سرعة دفع في المنصة، أو من 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. ويُدخَل إلى العناصر عند العنصر الذي كان عليه تركيز لوحة المفاتيح آخر مرة، وإلا فعند العنصر الساكن في موضع العنصر البارز.
  • مفتاحا السهم الأيمن والسهم الأيسر ينقلان التركيز إلى العنصر التالي والسابق. يقفان عند الطرفين، ولا يدوران إلا ما دام العرض الدوّار يدور. والمفتاحان Home و End ينقلان إلى العنصر الأول والأخير، حتى في صف يدور. وفي التخطيط من اليمين إلى اليسار ينقل السهم الأيسر إلى العنصر التالي.
  • نقل التركيز يأتي بالعنصر الذي عليه التركيز إلى موضع العنصر البارز، بأقرب ما تسمح به نهاية المدى، ومن الطريق الأقصر في صف يدور. وفي صف بعروض ثابتة وتمرير حر من البداية، يكتفي بأن يأتي بالعنصر كله إلى داخل المرئي.
  • المفتاحان Enter و Space يفعّلان العنصر الذي عليه التركيز. والضغطة التي تتحول إلى تمرير لا تفعّل العنصر الذي بدأت عليه.
  • النقاط شريط تمرير (slider) واحد تسمّيه label، وقيمته تسمية العنصر الحالي. مفاتيح الأسهم، والمفتاحان Home و End، والزيادة والإنقاص في المنصة تحرّك الصف موضعًا واحدًا. والنقطة الحالية تُميَّز بشكلها الممطوط، لا باللون وحده.
  • عنصر التحكم في التشغيل زر تسمّيه pauseLabel في أثناء التشغيل و playLabel في أثناء الإيقاف المؤقت. ليس له حالة ضغط (pressed)، فلا يُقرأ أبدًا «إيقاف مؤقت، مضغوط». وتفعيله يُبقي التركيز عليه. ورسما الإيقاف المؤقت والتشغيل فيه لا يُعكسان، وقبل أن يُحمَّل خط الأيقونات لا يُعرض اسم أي رسم نصًّا.
  • عنصرا التحكم السابق والتالي زرّان يسمّيهما previousLabel و nextLabel. وتفعيل أحدهما يُبقي التركيز عليه. عند طرفي صف لا يدور يُعطَّل العنصر، لكنه يحتفظ بالتركيز ويبقى في ترتيب المفتاح Tab. وحين يكونان مخفيين مع auto يبلغهما المفتاح Tab ويقرؤهما قارئ الشاشة، ويُظهرهما التركيز. وفي التخطيط من اليمين إلى اليسار يكون عنصر التحكم السابق على اليمين، وتُعكَس شارتا الاتجاه حيث تقول مجموعة الأيقونات ذلك.
  • يُعلَّق التشغيل التلقائي ما دام التركيز في أي موضع من العرض الدوّار، ولا ينقل التركيز أبدًا ولا يُعلِن شيئًا، ولا يعمل أبدًا حيث تكون الحركة مقلَّلة.
  • تُرسم حلقة التركيز داخل العنصر، حيث لا يستطيع الصف أن يقصّها، وحول النقاط وعنصر التحكم في التشغيل. وتظهر لتركيز لوحة المفاتيح فقط.
  • مساحة اللمس لكل عنصر هي حاويته مضافًا إليها نصف الفجوة من كل جانب، ولا تقل أبدًا عن الحد الأدنى للهدف، حتى للعنصر الصغير. والعنصر الذي ما زال يدخل أو يخرج عند الحافة أضيق من ذلك، ومساحة اللمس له لا تغطي أبدًا مساحة جاره. ومساحة اللمس لعنصر التحكم في التشغيل هي هدف اللمس، ومساحة اللمس للنقاط هي حاويتها كلها وارتفاع الصف.
  • ليس التمرير الطريقة الوحيدة أبدًا لبلوغ عنصر: عنصرا التحكم السابق والتالي يحرّكان الصف بضغطة واحدة من الفأرة (WCAG 2.5.7)، ومفاتيح الأسهم والنقاط وتركيز قارئ الشاشة تبلغ كل واحد منها.
  • يحتفظ العرض الدوّار بارتفاعه وعناصره عند أحجام النص الأكبر. لا يحمل نصًّا خاصًّا به، ومحتواك يتبع حجم النص بنفسه.
  • تبلّغ بنيات التنقيح (debug) عن عنصر بلا تسمية، وعن عرض دوّار بلا label، وعن عنصر تحكم في التشغيل بلا playLabel أو pauseLabel، وعن عنصرَي التحكم السابق والتالي بلا previousLabel أو nextLabel، وعن نقاط لا تتسع، وعن قيمة مجهولة للخاصية heroAlignment أو contentAlignment أو navigation، وعن قيمة للخاصية itemWidth أو autoplayInterval ليست عددًا موجبًا. ويبلّغ الويب أيضًا عن عنصر تفاعلي داخل محتوى عنصر.

فجوات معروفة في المنصات:

  • ليس في SwiftUI و React Native خاصية للموضع في المجموعة (position in set) لحاوية مخصصة، فيقوم عدّ قارئ الشاشة نفسه للعناصر مقام موضع كل عنصر وعدد العناصر. وليس في SwiftUI دور قائمة كذلك: العرض الدوّار حاوية اسمها قيمة label.
  • ليس في Compose دور قائمة. يعطي الصف حجم مجموعته ويعطي كل عنصر موضعه، مع دور الزر، فيُعلِن TalkBack مجموعة لا قائمة.
  • الويب وحده يستطيع أن يفحص محتوى عنصر، فالويب وحده يبلّغ عن عنصر تحكم داخله. وعلى المنصات الأخرى حفظ القاعدة عليك.
  • الويب: ينتقل موضع توقف المفتاح Tab إلى أي عنصر يأخذ التركيز، ومنه تركيز النقرة، حيث تسمّي المواصفة العنصر الذي كان عليه تركيز لوحة المفاتيح آخر مرة. ودفعة القلم السريعة تستقر على أقرب عنصر، لا على التالي. والمؤشر الافتراضي (virtual cursor) لقارئ شاشة لا ينقل التركيز يمرّر الصف كما يفعل المتصفح، من دون أن يأتي بالعنصر إلى موضع العنصر البارز.
  • في SwiftUI: العرض الدوّار دائمًا بارتفاع رمز الارتفاع الخاص به، لأن SwiftUI لا يستطيع أن يفرّق بين إطار (frame) واقتراح مكدّس (stack). حدِّد مقاسه برموز طبقة. ويتحرك الاستقرار بتباطؤ عرض التمرير (scroll view) نفسه، لا بحركة التمرير الخاصة بالعرض الدوّار، ولا يحدث فورًا حيث تكون الحركة مقلَّلة. ويبني كل عنصر ويضع كل واحد من جديد في كل إطار تمرير. ومفاتيح الأسهم وموضع توقف المفتاح 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، أبقِ عدد العناصر معتدلًا: العرض الدوّار هناك يبني كل عنصر، ومنها العناصر التي خارج المرئي.