Skip to content

Commit

Permalink
Fixed #2661 - New Image error event
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Jun 14, 2022
1 parent cdf42ed commit 9a419b9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api-generator/components/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const ImageEvents = [
{
name: "hide",
description: "Triggered when the preview overlay is hidden."
},
{
name: "error",
description: "Triggered when an error occurs while loading an image file."
}
];

Expand Down
6 changes: 6 additions & 0 deletions src/components/image/Image.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ declare class Image extends ClassComponent<ImageProps, ImageSlots, ImageEmits> {
* @memberof Image
*/
hide: () => void;
/**
* Triggered when an error occurs while loading an image file.
*
* @memberof Image
*/
error: () => void;
}

declare module '@vue/runtime-core' {
Expand Down
3 changes: 2 additions & 1 deletion src/components/image/Image.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import Portal from 'primevue/portal';
export default {
name: 'Image',
inheritAttrs: false,
emits: ['show', 'hide', 'error'],
props: {
preview: {
type: Boolean,
Expand Down Expand Up @@ -94,7 +95,7 @@ export default {
this.previewClick = false;
},
onError() {
this.$emit('onError');
this.$emit('error');
},
rotateRight() {
this.rotate += 90;
Expand Down
5 changes: 5 additions & 0 deletions src/views/image/ImageDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ import Image from 'primevue/image';
<td>hide</td>
<td>-</td>
<td>Triggered when the preview overlay is hidden.</td>
</tr>
<tr>
<td>error</td>
<td>-</td>
<td>Triggered when an error occurs while loading an image file.</td>
</tr>
</tbody>
</table>
Expand Down

0 comments on commit 9a419b9

Please sign in to comment.