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',
|
default: 'pi pi-eye',
|
||||||
description: 'Custom indicator icon.'
|
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',
|
name: 'pt',
|
||||||
type: 'any',
|
type: 'any',
|
||||||
|
|
|
@ -153,6 +153,16 @@ export interface ImageProps {
|
||||||
* @deprecated since v3.27.0. Use 'indicator' slot.
|
* @deprecated since v3.27.0. Use 'indicator' slot.
|
||||||
*/
|
*/
|
||||||
indicatorIcon?: string;
|
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.
|
* Uses to pass attributes to DOM elements inside the component.
|
||||||
* @type {ImagePassThroughOptions}
|
* @type {ImagePassThroughOptions}
|
||||||
|
|
|
@ -23,13 +23,13 @@
|
||||||
</slot>
|
</slot>
|
||||||
</button>
|
</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">
|
<slot name="zoomout">
|
||||||
<SearchMinusIcon v-bind="ptm('zoomOutIcon')" />
|
<SearchMinusIcon v-bind="ptm('zoomOutIcon')" />
|
||||||
</slot>
|
</slot>
|
||||||
</button>
|
</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">
|
<slot name="zoomin">
|
||||||
<SearchPlusIcon v-bind="ptm('zoomInIcon')" />
|
<SearchPlusIcon v-bind="ptm('zoomInIcon')" />
|
||||||
</slot>
|
</slot>
|
||||||
|
@ -98,6 +98,14 @@ export default {
|
||||||
indicatorIcon: {
|
indicatorIcon: {
|
||||||
type: String,
|
type: String,
|
||||||
default: undefined
|
default: undefined
|
||||||
|
},
|
||||||
|
zoomInDisabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
zoomOutDisabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mask: null,
|
mask: null,
|
||||||
|
@ -132,7 +140,13 @@ export default {
|
||||||
onPreviewImageClick() {
|
onPreviewImageClick() {
|
||||||
this.previewClick = true;
|
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) {
|
if (!this.previewClick) {
|
||||||
this.previewVisible = false;
|
this.previewVisible = false;
|
||||||
this.rotate = 0;
|
this.rotate = 0;
|
||||||
|
@ -198,6 +212,11 @@ export default {
|
||||||
if (focusTarget) {
|
if (focusTarget) {
|
||||||
focusTarget.focus();
|
focusTarget.focus();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
hidePreview() {
|
||||||
|
this.previewVisible = false;
|
||||||
|
this.rotate = 0;
|
||||||
|
this.scale = 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -219,8 +238,11 @@ export default {
|
||||||
imagePreviewStyle() {
|
imagePreviewStyle() {
|
||||||
return { transform: 'rotate(' + this.rotate + 'deg) scale(' + this.scale + ')' };
|
return { transform: 'rotate(' + this.rotate + 'deg) scale(' + this.scale + ')' };
|
||||||
},
|
},
|
||||||
zoomDisabled() {
|
isZoomInDisabled() {
|
||||||
return this.scale <= 0.5 || this.scale >= 1.5;
|
return this.zoomInDisabled || this.scale >= 1.5;
|
||||||
|
},
|
||||||
|
isZoomOutDisabled() {
|
||||||
|
return this.zoomOutDisabled || this.scale <= 0.5;
|
||||||
},
|
},
|
||||||
rightAriaLabel() {
|
rightAriaLabel() {
|
||||||
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.rotateRight : undefined;
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.rotateRight : undefined;
|
||||||
|
@ -300,6 +322,10 @@ export default {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.p-image-action.p-link[disabled] {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
.p-image-preview {
|
.p-image-preview {
|
||||||
transition: transform 0.15s;
|
transition: transform 0.15s;
|
||||||
max-width: 100vw;
|
max-width: 100vw;
|
||||||
|
|
Loading…
Reference in New Issue