imagePreview slot added

pull/3913/head
Burak Sağlam 2023-04-29 21:43:56 +03:00
parent aedc26d859
commit fc6230c29a
4 changed files with 17 additions and 2 deletions

View File

@ -52,6 +52,10 @@ const ImageSlots = [
{
name: 'close',
description: 'Custom content for the component close.'
},
{
name: 'imagePreview',
description: 'Custom content for the component preview.'
}
];

View File

@ -62,6 +62,10 @@ export interface ImageSlots {
* Custom close template.
*/
close(): VNode[];
/**
* Custom preview template.
*/
imagePreview(): VNode[];
}
export interface ImageEmits {}

View File

@ -41,7 +41,9 @@
</div>
<transition name="p-image-preview" @before-enter="onBeforeEnter" @enter="onEnter" @leave="onLeave" @before-leave="onBeforeLeave" @after-leave="onAfterLeave">
<div v-if="previewVisible">
<slot name="imagePreview" :previewImageClick="onPreviewImageClick" :imagePreviewStyle="imagePreviewStyle">
<img :src="$attrs.src" class="p-image-preview" :style="imagePreviewStyle" @click="onPreviewImageClick" />
</slot>
</div>
</transition>
</div>

View File

@ -3,8 +3,13 @@
<p>Enabling <i>preview</i> mode displays a modal layer when the image is clicked to provide transformation options such as rotating and zooming.</p>
</DocSectionText>
<div class="card flex justify-content-center">
<Image src="https://primefaces.org/cdn/primevue/images/galleria/galleria10.jpg" alt="Image" width="250" preview />
<Image src="https://primefaces.org/cdn/primevue/images/galleria/galleria10.jpg" alt="Image" width="250" preview>
<template #imagePreview="slotProps">
<img src="https://primefaces.org/cdn/primevue/images/galleria/galleria10.jpg" alt="Image" :style="slotProps.imagePreviewStyle" @click="slotProps.previewImageClick" />
</template>
</Image>
</div>
<DocSectionCode :code="code" />
</template>