Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Image add infinite props #22959

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/docs/en-US/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Besides the native features of img, support lazy load, custom placeholder and lo
| preview-src-list | allow big image preview | Array | — | - |
| z-index | set image preview z-index | Number | — | 2000 |
| initial-index | set image preview array index | Number | — | - |
| infinite | whether the viewer preview is infinite. | boolean | — | true |

### Events
| Event Name | Description | Parameters |
Expand Down
1 change: 1 addition & 0 deletions examples/docs/es/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ Además de las características nativas de img, soporte de carga perezosa, marca
| preview-src-list | permitir una vista previa grande de la imagen | Array | — | - |
| z-index | establecer el z-index de la vista previa de la imagen | Number | — | 2000 |
| initial-index | set image preview array index | Number | — | - |
| infinite | Si la vista previa del espectador es ilimitada. | boolean | — | true |

### Eventos
| Nombre del evento | Descripción | Parámetros |
Expand Down
1 change: 1 addition & 0 deletions examples/docs/fr-FR/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ En plus des propriétés natives de img, ce composant supporte le lazy loading,
| preview-src-list | allow big image preview | Array | — | - |
| z-index | set image preview z-index | Number | — | 2000 |
| initial-index | set image preview array index | Number | — | - |
| infinite | Voir si l'aperçu du spectateur est illimité. | boolean | — | true |

### Évènements
| Nom | Description | Paramètres |
Expand Down
1 change: 1 addition & 0 deletions examples/docs/zh-CN/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
| preview-src-list | 开启图片预览功能 | Array | — | - |
| z-index | 设置图片预览的 z-index | Number | — | 2000 |
| initial-index | 图片预览初始图片index | Number | — | - |
| infinite | 是否可以无限循环预览 | boolean | — | true |

### Events
| 事件名称 | 说明 | 回调参数 |
Expand Down
33 changes: 19 additions & 14 deletions packages/image/src/image-viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,25 @@
</div>
<!-- CANVAS -->
<div class="el-image-viewer__canvas">
<img
v-for="(url, i) in urlList"
v-if="i === index"
ref="img"
class="el-image-viewer__img"
:key="url"
:src="currentImg"
:style="imgStyle"
@load="handleImgLoad"
@error="handleImgError"
@mousedown="handleMouseDown">
<template v-for="(url, i) in urlList">
<img
v-if="i === index"
ref="img"
class="el-image-viewer__img"
:key="url"
:src="currentImg"
:style="imgStyle"
@load="handleImgLoad"
@error="handleImgError"
@mousedown="handleMouseDown" />
</template>
</div>
</div>
</transition>
</template>

<script>
import Locale from 'element-ui/src/mixins/locale';
import { on, off } from 'element-ui/src/utils/dom';
import { rafThrottle, isFirefox } from 'element-ui/src/utils/util';
import { PopupManager } from 'element-ui/src/utils/popup';
Expand All @@ -71,7 +73,7 @@ const mousewheelEventName = isFirefox() ? 'DOMMouseScroll' : 'mousewheel';

export default {
name: 'elImageViewer',

mixins: [Locale],
props: {
urlList: {
type: Array,
Expand Down Expand Up @@ -100,14 +102,17 @@ export default {
maskClosable: {
type: Boolean,
default: true
},
infinite: {
type: Boolean,
default: true
}
},

data() {
return {
index: this.initialIndex,
isShow: false,
infinite: true,
loading: false,
mode: Mode.CONTAIN,
transform: {
Expand Down Expand Up @@ -230,7 +235,7 @@ export default {
},
handleImgError(e) {
this.loading = false;
e.target.alt = '加载失败';
e.target.alt = this.t('el.image.error');
},
handleMouseDown(e) {
if (this.loading || e.button !== 0) return;
Expand Down
2 changes: 1 addition & 1 deletion packages/image/src/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
:style="imageStyle"
:class="{ 'el-image__inner--center': alignCenter, 'el-image__preview': preview }">
<template v-if="preview">
<image-viewer :z-index="zIndex" :initial-index="imageIndex" v-if="showViewer" :on-close="closeViewer" :url-list="previewSrcList"/>
<image-viewer :z-index="zIndex" v-bind="$attrs" :initial-index="imageIndex" v-if="showViewer" :on-close="closeViewer" :url-list="previewSrcList"/>
</template>
</div>
</template>
Expand Down
8 changes: 8 additions & 0 deletions packages/theme-chalk/src/image.scss
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@
background-color: #606266;
border-color: #fff;
left: 40px;
@include when(disabled) {
cursor: not-allowed;
opacity: 0.5;
}
}

@include e(next){
Expand All @@ -135,6 +139,10 @@
border-color: #fff;
right: 40px;
text-indent: 2px;
@include when(disabled) {
cursor: not-allowed;
opacity: 0.5;
}
}

@include e(mask) {
Expand Down
3 changes: 3 additions & 0 deletions types/image.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export declare class ElImage extends ElementUIComponent {
/** Whether to use lazy load */
lazy: boolean

/** Whether to use infinite */
infinite: boolean

/** Scroll container that to add scroll listener when using lazy load */
scrollContainer: string | HTMLElement

Expand Down
Loading