Документация
С чего начать
Подключите модуль:
import { GalleriaModule } from 'primeng/galleria';
Встройте компонент с помощью тегаp-galleria
.
Полностью работоспособный пример смотрите ниже.
Пример
<p-galleria [(value)]="images" [responsiveOptions]="responsiveOptions" [containerStyle]="{ 'max-width': '640px' }" [numVisible]="5">
<ng-template pTemplate="item" let-item>
<img [src]="item.previewImageSrc" style="width: 100%" />
</ng-template>
<ng-template pTemplate="thumbnail" let-item>
<div class="p-grid p-nogutter p-justify-center">
<img [src]="item.thumbnailImageSrc" />
</div>
</ng-template>
</p-galleria>
Количество элементов в галерее
Количество элементов на странице определяется с помощью свойстваnumVisible
, например, в нашем случае:[numVisible]="5"
.
Адаптив
Для адаптивного отображения количества элементов в галерее его можно определить с помощью свойстваresponsiveOptions
, которое должно представлять собой массив объектов, брейкпоинты которых определяют максимальную ширину для применения настроек.
responsiveOptions: any[] = [
{
breakpoint: '1024px',
numVisible: 5,
},
{
breakpoint: '768px',
numVisible: 3,
},
{
breakpoint: '560px',
numVisible: 1,
},
];
Header и Footer
Доступно добавление пользовательского контента с помощью свойств верхнего и нижнего колонтитулов.
Header
Footer
Индикаторы
Индикаторы позволяют быстро перемещаться между элементами. Установите параметрshowIndicators
для отображения индикаторов, которые можно дополнительно настроить с помощью свойствchangeItemOnIndicatorHover
,showIndicatorsOnItem
иindicatorsPosition
.
Свойства
Name | Type | Default | Description |
---|---|---|---|
id | string | null | Unique identifier of the element. |
value | array | null | An array of objects to display. |
activeIndex | number | 0 | Index of the first item. |
fullScreen | boolean | false | Whether to display the component on fullscreen. |
visible | boolean | false | Specifies the visibility of the mask on fullscreen mode. |
numVisible | number | 3 | Number of items per page. |
responsiveOptions | any | null | An array of options for responsive design. |
showItemNavigators | boolean | false | Whether to display navigation buttons in preview container. |
showThumbnailNavigators | boolean | true | Whether to display navigation buttons in thumbnail container. |
showItemNavigatorsOnHover | boolean | false | Whether to display navigation buttons on preview container's hover. |
changeItemOnIndicatorHover | boolean | false | When enabled, preview item is changed on indicator item's hover. |
circular | boolean | false | Defines if scrolling would be infinite. |
autoPlay | boolean | false | Items are displayed with a slideshow in autoPlay mode. |
transitionInterval | number | 4000 | Time in milliseconds to scroll items. |
showThumbnails | boolean | true | Whether to display thumbnail container. |
thumbnailsPosition | string | bottom | Position of thumbnails. Valid values are "bottom", "top", "left" and "right". |
verticalThumbnailViewPortHeight | string | 300px | Height of the viewport in vertical thumbnail. |
showIndicators | boolean | false | Whether to display indicator container. |
showIndicatorsOnItem | boolean | false | When enabled, indicator container is displayed on preview container. |
indicatorsPosition | string | bottom | Position of indicators. Valid values are "bottom", "top", "left" and "right". |
baseZIndex | number | 0 | Base zIndex value to use in layering. |
maskClass | string | null | Style class of the mask on fullscreen mode. |
containerStyle | string | null | Inline style of the component on fullscreen mode. Otherwise, the 'style' property can be used. |
galleriaClass | string | null | Style class of the component on fullscreen mode. Otherwise, the 'class' property can be used. |
showTransitionOptions | string | 150ms cubic-bezier(0, 0, 0.2, 1)/td> | Transition options of the show animation. |
hideTransitionOptions | string | 150ms cubic-bezier(0, 0, 0.2, 1) | Transition options of the hide animation. |
Шаблоны
Name | Parameters |
---|---|
header | - |
indicator | $implicit: Data of the item |
caption | - |
footer | - |
Стилизация
Name | Element |
---|---|
p-galleria | Container element. |
p-galleria-header | Header section. |
p-galleria-footer | Footer section. |
p-galleria-item-wrapper | Preview content element. It contains preview and indicator containers. |
p-galleria-item-container | Container of the preview content. It contains navigation buttons, preview item and caption content. |
p-galleria-indicators | Container of the indicators. It contains indicator items. |
p-galleria-thumbnail-wrapper | Thumbnail content element. |
p-galleria-thumbnail-container | Container of the thumbnail content. It contains navigation buttons and thumbnail items. |
p-galleria-caption | Content of the preview caption. |