Merge pull request #3847 from primefaces/issue-2948
Image: zoomIn and zoomOut props addedpull/3958/head
commit
a81f980647
|
@ -11,6 +11,18 @@ const ImageProps = [
|
|||
default: 'pi pi-eye',
|
||||
description: 'Custom indicator icon.'
|
||||
},
|
||||
{
|
||||
name: 'zoomInDisabled',
|
||||
type: 'boolean',
|
||||
default: 'false',
|
||||
description: 'Disable the zoom-in button'
|
||||
},
|
||||
{
|
||||
name: 'zoomOutDisabled',
|
||||
type: 'boolean',
|
||||
default: 'false',
|
||||
description: 'Disable the zoom-out button'
|
||||
},
|
||||
{
|
||||
name: 'pt',
|
||||
type: 'any',
|
||||
|
|
|
@ -153,6 +153,16 @@ export interface ImageProps {
|
|||
* @deprecated since v3.27.0. Use 'indicator' slot.
|
||||
*/
|
||||
indicatorIcon?: string;
|
||||
/**
|
||||
* Disable the zoom-in button
|
||||
* @defaultValue false
|
||||
*/
|
||||
zoomInDisabled?: boolean | undefined;
|
||||
/**
|
||||
* Disable the zoom-out button
|
||||
* @defaultValue false
|
||||
*/
|
||||
zoomOutDisabled?: boolean | undefined;
|
||||
/**
|
||||
* Uses to pass attributes to DOM elements inside the component.
|
||||
* @type {ImagePassThroughOptions}
|
||||
|
|
|
@ -23,13 +23,13 @@
|
|||
</slot>
|
||||
</button>
|
||||
|
||||
<button class="p-image-action p-link" @click="zoomOut" type="button" :disabled="zoomDisabled" :aria-label="zoomOutAriaLabel" v-bind="ptm('zoomOutButton')">
|
||||
<button class="p-image-action p-link" @click="zoomOut" type="button" :disabled="isZoomOutDisabled" :aria-label="zoomOutAriaLabel" v-bind="ptm('zoomOutButton')">
|
||||
<slot name="zoomout">
|
||||
<SearchMinusIcon v-bind="ptm('zoomOutIcon')" />
|
||||
</slot>
|
||||
</button>
|
||||
|
||||
<button class="p-image-action p-link" @click="zoomIn" type="button" :disabled="zoomDisabled" :aria-label="zoomInAriaLabel" v-bind="ptm('zoomInButton')">
|
||||
<button class="p-image-action p-link" @click="zoomIn" type="button" :disabled="isZoomInDisabled" :aria-label="zoomInAriaLabel" v-bind="ptm('zoomInButton')">
|
||||
<slot name="zoomin">
|
||||
<SearchPlusIcon v-bind="ptm('zoomInIcon')" />
|
||||
</slot>
|
||||
|
@ -98,6 +98,14 @@ export default {
|
|||
indicatorIcon: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
zoomInDisabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
zoomOutDisabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
mask: null,
|
||||
|
@ -132,7 +140,13 @@ export default {
|
|||
onPreviewImageClick() {
|
||||
this.previewClick = true;
|
||||
},
|
||||
onMaskClick() {
|
||||
onMaskClick(event) {
|
||||
const isActionbarTarget = [event.target.classList].includes('p-image-action') || event.target.closest('.p-image-action');
|
||||
|
||||
if (isActionbarTarget) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.previewClick) {
|
||||
this.previewVisible = false;
|
||||
this.rotate = 0;
|
||||
|
@ -198,6 +212,11 @@ export default {
|
|||
if (focusTarget) {
|
||||
focusTarget.focus();
|
||||
}
|
||||
},
|
||||
hidePreview() {
|
||||
this.previewVisible = false;
|
||||
this.rotate = 0;
|
||||
this.scale = 1;
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -219,8 +238,11 @@ export default {
|
|||
imagePreviewStyle() {
|
||||
return { transform: 'rotate(' + this.rotate + 'deg) scale(' + this.scale + ')' };
|
||||
},
|
||||
zoomDisabled() {
|
||||
return this.scale <= 0.5 || this.scale >= 1.5;
|
||||
isZoomInDisabled() {
|
||||
return this.zoomInDisabled || this.scale >= 1.5;
|
||||
},
|
||||
isZoomOutDisabled() {
|
||||
return this.zoomOutDisabled || this.scale <= 0.5;
|
||||
},
|
||||
rightAriaLabel() {
|
||||
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.rotateRight : undefined;
|
||||
|
@ -300,6 +322,10 @@ export default {
|
|||
align-items: center;
|
||||
}
|
||||
|
||||
.p-image-action.p-link[disabled] {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.p-image-preview {
|
||||
transition: transform 0.15s;
|
||||
max-width: 100vw;
|
||||
|
|
Loading…
Reference in New Issue