Blazor Carousel Overview
Ignite UI for Blazor 캐러셀은 텍스트 슬라이드, 링크 및 기타 html 요소가 있는 이미지 컬렉션을 앞뒤로 탐색하는 사용자를 위해 슬라이드쇼와 같은 웹 환경을 만들 수 있는 가장 유연한 방법을 제공하는 응답성이 뛰어난 경량 구성 요소입니다.
Blazor Carousel 구성 요소를 사용하면 애니메이션, 슬라이드 전환 및 사용자 지정을 사용할 수 있으므로 인터페이스를 쉽게 조정하고 사용자 정의 캐러셀 Blazor 구축할 수 있습니다.
Blazor Carousel Example
아래에 보이는 Blazor Carousel 데모는 이미지만 포함된 슬라이드를 보여줍니다.
Usage
사용하기 전에 다음과 같이 등록해야 합니다. IgbCarousel
// in Program.cs file
builder.Services.AddIgniteUIBlazor(typeof(IgbCarouselModule));
또한 구성 요소에 스타일을 적용하려면 추가 CSS 파일을 연결해야 합니다 IgbCarousel
. Blazor 웹 어셈블리 프로젝트의 wwwroot/index.html 파일 또는 Blazor 서버 프로젝트의 Pages/_Host.cshtml 파일에 다음을 배치해야 합니다.
<link href="_content/IgniteUI.Blazor/themes/light/bootstrap.css" rel="stylesheet" />
Ignite UI for Blazor에 대한 전체 소개를 보려면 시작하기 항목을 읽어보세요.
이제 Ignite UI for Blazor Carousel을 가져왔으므로 및 해당 슬라이드의 IgbCarousel
기본 구성부터 시작할 수 있습니다.
선택기를 IgbCarousel
사용하여 슬라이드를 래핑합니다. 슬라이드에는 다른 구성 요소를 포함하여 유효한 html 콘텐츠가 포함될 수 있습니다.
<IgbCarousel>
<IgbCarouselSlide>
<img src="assets/images/carousel/ignite-ui-angular-indigo-design.png" />
</IgbCarouselSlide>
<IgbCarouselSlide>
<img src="assets/images/carousel/slider-image-chart.png" />
</IgbCarouselSlide>
<IgbCarouselSlide>
<img src="assets/images/carousel/ignite-ui-angular-charts.png" />
</IgbCarouselSlide>
</IgbCarousel>
슬라이드가 기본적으로 활성화되도록 하려면 다음 속성을 사용합니다 Active
.
<IgbCarousel>
...
<IgbCarouselSlide>
...
</IgbCarouselSlide>
<IgbCarouselSlide Active="true">
...
</IgbCarouselSlide>
</IgbCarousel>
[!NOTE] If no active slide is set, the first one will be set by default. If there are multiple active slides on initial rendering or subsequent updates, only the last one will be taken into account.
Examples
Carousel Configuration
기본적으로 의 IgbCarousel
DisableLoop
속성은 false로 설정되어 있습니다(다음 작업을 사용하여 탐색하여 첫 번째 슬라이드가 마지막 슬라이드 뒤에 오거나 이전 작업을 사용하여 첫 번째 슬라이드 뒤에 올 때 반복이 발생합니다). 루핑 동작은 속성 값을 DisableLoop
true로 설정하여 비활성화할 수 있습니다.
<IgbCarousel DisableLoop="true">
...
</IgbCarousel>
각 슬라이드 인덱스를 추적하기 위해 캐러셀에는 기본적으로 캐러셀에 배치 end
되는 표시기가 있습니다. 이 동작을 변경하려면 속성을 사용하여 IndicatorsOrientation
할당합니다 start
.
<IgbCarousel IndicatorsOrientation="@CarouselIndicatorsOrientation.Start">
...
</IgbCarousel>
기본적으로 탐색 IgbCarousel
버튼과 표시기가 표시됩니다. HideIndicators
이 속성을 사용하여 표시기를 숨기고 HideNavigation
속성을 사용하여 탐색 단추를 숨깁니다.
<IgbCarousel HideNavigation="true" HideIndicators="true">
...
</IgbCarousel>
IgbCarousel
수직 모드를 지원합니다. Vertical
속성을 사용하여 사용하도록 설정합니다.
<IgbCarousel Vertical="true">
...
</IgbCarousel>
Custom indicators
To add Blazor custom carousel indicators, use the IgbCarouselIndicator
:
<IgbCarousel>
<IgbCarouselIndicator>
<span>🤍</span>
<span slot="active">❤️</span>
</IgbCarouselIndicator>
<IgbCarouselIndicator>
<span>🤍</span>
<span slot="active">❤️</span>
</IgbCarouselIndicator>
<IgbCarouselSlide>
<img src="assets/images/card/media/the_red_ice_forest.jpg"/>
</IgbCarouselSlide>
<IgbCarouselSlide>
<img src="assets/images/card/media/yosemite.jpg"/>
</IgbCarouselSlide>
</IgbCarousel>
Ignite UI for Blazor Carousel 구성 요소를 사용하면 단일 지표의 활성 및 비활성 상태에 대해 서로 다른 요소를 사용할 수 있습니다. 인디케이터를 선언할 때 각 슬롯에 대해 두 개의 요소(empty 및 active)를 제공해야 하며, 이는 동일하더라도 마찬가지입니다.
Custom navigation buttons
이를 위해 및 next-button
슬롯을 previous-button
사용합니다.
<IgbCarousel>
<IgbIcon slot="previous-button" IconName="previous" Collection="material"></IgbIcon>
<IgbIcon slot="next-button" IconName="next" Collection="material"></IgbIcon>
...
</IgbCarousel>
Slide containing other components
이 캐러셀에는 양식과 이미지가 포함된 슬라이드가 포함됩니다.
<IgbCarousel>
<IgbCarouselSlide>
<div>
<img src="assets/images/svg/carousel/SignUp.svg">
<form>
<IgbInput DisplayType="@InputType.Text" Placeholder="Username">
<IgbIcon slot="prefix" IconName="person" Collection="material" @ref="iconRef"></IgbIcon>
</IgbInput>
<IgbInput DisplayType="@InputType.Password" Placeholder="Password">
<IgbIcon slot="prefix" IconName="password" Collection="material"></IgbIcon>
</IgbInput>
<IgbButton DisplayType="@ButtonBaseType.Reset">Sign In</IgbButton>
</form>
</div>
</IgbCarouselSlide>
<IgbCarouselSlide>
<div>
<img src="assets/images/svg/carousel/Route.svg">
<form>
<IgbInput DisplayType="@InputType.Text" Placeholder="Search">
<IgbIcon slot="prefix" IconName="search" Collection="material"></IgbIcon>
</IgbInput>
<IgbButton DisplayType="@ButtonBaseType.Reset">Search</IgbButton>
</form>
</div>
</IgbCarouselSlide>
</IgbCarousel>
데모
Animations
애니메이션 슬라이드 전환은 최종 사용자에게 회전판과 상호 작용할 때 좋은 경험을 제공합니다.
캐러셀은 기본적으로 애니메이션을 slide
사용하도록 구성되지만 대체 애니메이션으로도 지원됩니다 fade
.
Use the AnimationType
property to change the animation.
<IgbCarousel AnimationType="@CarouselAnimationType.Fade">
...
</IgbCarousel>
Setting none
to the AnimationType
property disables the animations.
데모
아래 데모는 캐러셀이 지원하는 다양한 유형의 애니메이션을 보여줍니다.
Navigation
전환 및 탐색은 캐러셀의 가장 중요한 기능입니다.
캐러셀의 탐색은 사용자가 모바일 장치에서 탐색 버튼, 표시기, 키보드 탐색 및 터치 조작을 통해 처리할 수 있습니다.
Touch gestures
기본적으로 캐러셀은 모든 터치 지원 장치에서 사용할 수 있습니다.
캐러셀 애니메이션은 터치 장치에서 완벽하게 지원되므로 캐러셀은 모든 플랫폼과 일관되고 프로그레시브 웹 애플리케이션(PWA)에서 사용될 때 훌륭합니다.
키보드 탐색
- 탐색 버튼
Space
/Enter
key - 다음/이전 슬라이드로 이동합니다.
- 지표
Arrow Left
키 - 이전(오른쪽에서 왼쪽 모드에서 다음) 슬라이드로 이동합니다.Arrow Right
키 - 다음(오른쪽에서 왼쪽 모드의 이전) 슬라이드로 이동합니다.Home
키 - 첫 번째(오른쪽에서 왼쪽 모드의 마지막) 슬라이드로 이동합니다.End
키 - 마지막(오른쪽에서 왼쪽 모드의 첫 번째) 슬라이드로 이동합니다.
Automatic transitioning
IgbCarousel
사용자 상호 작용 없이 슬라이드를 자동으로 변경하도록 쉽게 구성할 수 있습니다. 이렇게 하면 속성에 대한 Interval
전환 간격만 설정하여 자신만의 슬라이드 쇼를 만들 수 있으며, 이 간격은 슬라이드 전환 사이의 시간(밀리초)을 결정합니다.
[!NOTE] Hovering the mouse over any carousel content or moving keyboard focus to any of the carousel content pauses automatic transitioning. Automatic transitioning resumes when the mouse moves away from the carousel or when keyboard focus moves out of the carousel content. This can be prevented by setting
DisablePauseOnInteraction
property to true.
<IgbCarousel Interval="2000" DisablePauseOnInteraction="true">
...
</IgbCarousel>
Advanced Example
루핑이 활성화된 완전 자동화된 캐러셀을 만들어 보겠습니다. 표시기를 각 슬라이드의 썸네일 표현으로 구성합니다.
이 목표를 달성하려면 캐러셀에 대해 다음 구성을 수행해야 합니다.
- 속성을 활성화합니다.
DisablePauseOnInteraction
- enable the
HideNavigation
property - 속성을 활성화합니다.
Vertical
- add transition
Interval
- add custom
IgbCarouselIndicator
for each slide
캐러셀은 템플릿에서 다음과 같이 표시됩니다.
<IgbCarousel DisablePauseOnInteraction="true"
HideNavigation="true"
Interval="2000"
Vertical="true"
AnimationType="@CarouselAnimationType.Fade">
<IgbCarouselIndicator>
<img class="blurred" src="assets/images/carousel/WonderfulCoastThumb.png" width="50" height="60" />
<img slot="active" src="assets/images/carousel/WonderfulCoastThumb.png" width="50" height="60" />
</IgbCarouselIndicator>
<IgbCarouselIndicator>
<img class="blurred" src="assets/images/carousel/CulturalDipThumb.png" width="50" height="60" />
<img slot="active" src="assets/images/carousel/CulturalDipThumb.png" width="50" height="60" />
</IgbCarouselIndicator>
<IgbCarouselIndicator>
<img class="blurred" src="assets/images/carousel/GoldenBeachesThumb.png" width="50" height="60" />
<img slot="active" src="assets/images/carousel/GoldenBeachesThumb.png" width="50" height="60" />
</IgbCarouselIndicator>
<IgbCarouselIndicator>
<img class="blurred" src="assets/images/carousel/IslandOfHistoryThumb.png" width="50" height="60" />
<img slot="active" src="assets/images/carousel/IslandOfHistoryThumb.png" width="50" height="60" />
</IgbCarouselIndicator>
<IgbCarouselIndicator>
<img class="blurred" src="assets/images/carousel/AmazingBridgeThumb.png" width="50" height="60" />
<img slot="active" src="assets/images/carousel/AmazingBridgeThumb.png" width="50" height="60" />
</IgbCarouselIndicator>
<IgbCarouselSlide>
<img src="assets/images/carousel/WonderfulCoast.png" />
</IgbCarouselSlide>
<IgbCarouselSlide>
<img src="assets/images/carousel/CulturalDip.png" />
</IgbCarouselSlide>
<IgbCarouselSlide>
<img src="assets/images/carousel/GoldenBeaches.png" />
</IgbCarouselSlide>
<IgbCarouselSlide>
<img src="assets/images/carousel/IslandOfHistory.png" />
</IgbCarouselSlide>
<IgbCarouselSlide>
<img src="assets/images/carousel/AmazingBridge.png" />
</IgbCarouselSlide>
</IgbCarousel>
이러한 구성의 결과는 다음과 같습니다.
Accessibility
WAI-ARIA Roles, States, and Properties
- Carousel 기본 요소 역할은 특정 목적과 관련된 콘텐츠가 포함된 섹션인
region
이며 사용자는 쉽게 탐색할 수 있기를 원할 것입니다. - 캐러셀 표시기에는 역할
tab
있습니다. 사용자에게 렌더링할 탭 콘텐츠를 선택하기 위한 메커니즘을 제공하는 그룹화 레이블입니다. - 탭 집합(캐러셀 표시기)의 컨테이너 역할을 하는 요소는 역할
tablist
이 있습니다. - 각 슬라이드 요소는
tabpanel
역할로 설정됩니다.
ARIA support
캐러셀 구성 요소
- Attributes
- aria-roledescription을 "carousel"로 설정합니다.
- aria-live- 스크린 리더가 라이브 영역에 대한 업데이트를 처리해야 하는 우선 순위를 설정하는 데 사용되며, 가능한 설정은 다음과 같습니다.off 및 polite. 기본 설정은 polite 이며 슬라이드 집합의 컨테이너 역할을 하는 요소로 설정됩니다.
Interval
옵션이 설정되고 캐러셀이 재생 중인 상태이면 aria-live 속성이 off로 설정됩니다. - aria-label (navigation buttons) - "Previous slide"/"Next slide".
Slide component
- Attributes
- id - "igc-carousel-slide-${incremented_number}" 패턴을 따릅니다.
- aria-roledescription을 "slide"로 설정합니다.
- aria-label은 "${total}의 ${index + 1}" 패턴을 따릅니다.
Indicator component
- Attributes
- aria-label은 "Slide ${index + 1}" 패턴을 따릅니다.
- aria-selected는 활성 슬라이드에 따라 true 또는 false로 설정됩니다.