Компоненты PrimeNG
Galleria
Документация

Документация

С чего начать

Подключите модуль:

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.

Свойства

NameTypeDefaultDescription
idstringnullUnique identifier of the element.
valuearraynullAn array of objects to display.
activeIndexnumber0Index of the first item.
fullScreenbooleanfalseWhether to display the component on fullscreen.
visiblebooleanfalseSpecifies the visibility of the mask on fullscreen mode.
numVisiblenumber3Number of items per page.
responsiveOptionsanynullAn array of options for responsive design.
showItemNavigatorsbooleanfalseWhether to display navigation buttons in preview container.
showThumbnailNavigatorsbooleantrueWhether to display navigation buttons in thumbnail container.
showItemNavigatorsOnHoverbooleanfalseWhether to display navigation buttons on preview container's hover.
changeItemOnIndicatorHoverbooleanfalseWhen enabled, preview item is changed on indicator item's hover.
circularbooleanfalseDefines if scrolling would be infinite.
autoPlaybooleanfalseItems are displayed with a slideshow in autoPlay mode.
transitionIntervalnumber4000Time in milliseconds to scroll items.
showThumbnailsbooleantrueWhether to display thumbnail container.
thumbnailsPositionstringbottomPosition of thumbnails. Valid values are "bottom", "top", "left" and "right".
verticalThumbnailViewPortHeightstring300pxHeight of the viewport in vertical thumbnail.
showIndicatorsbooleanfalseWhether to display indicator container.
showIndicatorsOnItembooleanfalseWhen enabled, indicator container is displayed on preview container.
indicatorsPositionstringbottomPosition of indicators. Valid values are "bottom", "top", "left" and "right".
baseZIndexnumber0Base zIndex value to use in layering.
maskClassstringnullStyle class of the mask on fullscreen mode.
containerStylestringnullInline style of the component on fullscreen mode. Otherwise, the 'style' property can be used.
galleriaClassstringnullStyle class of the component on fullscreen mode. Otherwise, the 'class' property can be used.
showTransitionOptionsstring150ms cubic-bezier(0, 0, 0.2, 1)/td>Transition options of the show animation.
hideTransitionOptionsstring150ms cubic-bezier(0, 0, 0.2, 1)Transition options of the hide animation.

Шаблоны

NameParameters
header-
indicator$implicit: Data of the item
caption-
footer-

Стилизация

NameElement
p-galleriaContainer element.
p-galleria-headerHeader section.
p-galleria-footerFooter section.
p-galleria-item-wrapperPreview content element. It contains preview and indicator containers.
p-galleria-item-containerContainer of the preview content. It contains navigation buttons, preview item and caption content.
p-galleria-indicatorsContainer of the indicators. It contains indicator items.
p-galleria-thumbnail-wrapperThumbnail content element.
p-galleria-thumbnail-containerContainer of the thumbnail content. It contains navigation buttons and thumbnail items.
p-galleria-captionContent of the preview caption.