Refactored Image

pull/5677/head
Cagatay Civici 2024-04-10 09:16:00 +03:00
parent 9c5251a2a1
commit 774782a778
3 changed files with 22 additions and 17 deletions

View File

@ -41,7 +41,7 @@
</slot> </slot>
</button> </button>
</div> </div>
<transition name="p-image-preview" @before-enter="onBeforeEnter" @enter="onEnter" @leave="onLeave" @before-leave="onBeforeLeave" @after-leave="onAfterLeave" v-bind="ptm('transition')"> <transition name="p-image-original" @before-enter="onBeforeEnter" @enter="onEnter" @leave="onLeave" @before-leave="onBeforeLeave" @after-leave="onAfterLeave" v-bind="ptm('transition')">
<div v-if="previewVisible" v-bind="ptm('previewContainer')"> <div v-if="previewVisible" v-bind="ptm('previewContainer')">
<slot name="preview" :class="cx('preview')" :style="imagePreviewStyle" :onClick="onPreviewImageClick" :previewCallback="onPreviewImageClick"> <slot name="preview" :class="cx('preview')" :style="imagePreviewStyle" :onClick="onPreviewImageClick" :previewCallback="onPreviewImageClick">
<img :src="$attrs.src" :class="cx('preview')" :style="imagePreviewStyle" @click="onPreviewImageClick" v-bind="ptm('preview')" /> <img :src="$attrs.src" :class="cx('preview')" :style="imagePreviewStyle" @click="onPreviewImageClick" v-bind="ptm('preview')" />

View File

@ -4,30 +4,30 @@ const classes = {
root: ({ props }) => [ root: ({ props }) => [
'p-image p-component', 'p-image p-component',
{ {
'p-image-preview-container': props.preview 'p-image-preview': props.preview
} }
], ],
image: ({ props }) => props.image, image: ({ props }) => props.image,
button: 'p-image-preview-indicator', button: 'p-image-preview-mask',
icon: 'p-image-preview-icon', icon: 'p-image-preview-icon',
mask: 'p-image-mask p-component-overlay p-component-overlay-enter', mask: 'p-image-mask p-component-overlay p-component-overlay-enter',
toolbar: 'p-image-toolbar', toolbar: 'p-image-toolbar',
rotateRightButton: 'p-image-action p-link', rotateRightButton: 'p-image-action p-image-rotate-right-button',
rotateLeftButton: 'p-image-action p-link', rotateLeftButton: 'p-image-action p-image-rotate-left-button',
zoomOutButton: ({ instance }) => [ zoomOutButton: ({ instance }) => [
'p-image-action p-link', 'p-image-action p-image-zoom-out-button',
{ {
'p-disabled': instance.isZoomOutDisabled 'p-disabled': instance.isZoomOutDisabled
} }
], ],
zoomInButton: ({ instance }) => [ zoomInButton: ({ instance }) => [
'p-image-action p-link', 'p-image-action p-image-zoom-in-button',
{ {
'p-disabled': instance.isZoomInDisabled 'p-disabled': instance.isZoomInDisabled
} }
], ],
closeButton: 'p-image-action p-link', closeButton: 'p-image-action p-image-close-button',
preview: 'p-image-preview' preview: 'p-image-original'
}; };
export default BaseStyle.extend({ export default BaseStyle.extend({

View File

@ -7,13 +7,13 @@ export default {
--p-mask-background: ${dt('image.mask.background')}; --p-mask-background: ${dt('image.mask.background')};
} }
.p-image-preview-container { .p-image-preview {
position: relative; position: relative;
display: inline-flex; display: inline-flex;
line-height: 0; line-height: 0;
} }
.p-image-preview-indicator { .p-image-preview-mask {
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
@ -32,7 +32,7 @@ export default {
transition: background-color ${dt('transition.duration')}; transition: background-color ${dt('transition.duration')};
} }
.p-image-preview-container:hover > .p-image-preview-indicator { .p-image-preview:hover > .p-image-preview-mask {
opacity: 1; opacity: 1;
cursor: pointer; cursor: pointer;
background: ${dt('image.preview.indicator.background')}; background: ${dt('image.preview.indicator.background')};
@ -60,6 +60,11 @@ export default {
color: ${dt('image.action.color')}; color: ${dt('image.action.color')};
background: transparent; background: transparent;
width: 3rem; width: 3rem;
margin: 0;
padding: 0;
border: 0 none;
cursor: pointer;
user-select: none;
height: 3rem; height: 3rem;
border-radius: 50%; border-radius: 50%;
outline-color: transparent; outline-color: transparent;
@ -86,22 +91,22 @@ export default {
pointer-events: auto; pointer-events: auto;
} }
.p-image-preview { .p-image-original {
transition: transform 0.15s; transition: transform 0.15s;
max-width: 100vw; max-width: 100vw;
max-height: 100vh; max-height: 100vh;
} }
.p-image-preview-enter-active { .p-image-original-enter-active {
transition: all 150ms cubic-bezier(0, 0, 0.2, 1); transition: all 150ms cubic-bezier(0, 0, 0.2, 1);
} }
.p-image-preview-leave-active { .p-image-original-leave-active {
transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1); transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
} }
.p-image-preview-enter-from, .p-image-original-enter-from,
.p-image-preview-leave-to { .p-image-original-leave-to {
opacity: 0; opacity: 0;
transform: scale(0.7); transform: scale(0.7);
} }