Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

image: apply various fixes #18

Merged
merged 1 commit into from
Mar 30, 2020
Merged

image: apply various fixes #18

merged 1 commit into from
Mar 30, 2020

Conversation

CarterLi
Copy link

@CarterLi CarterLi commented Mar 30, 2020

  1. set preview :initial-index to 0 if src is not in previewSrcList
    fix: The first list is displayed by default when there is no src in the previewSrcList ElemeFE/element#18871
    and also fix preview example
    如果previewSrcList里没有当前显示的图片url,默认预览第一张图片(example里的情况)
  2. fix ESC won't close preview for the second time
    修复第二次打开预览界面后ESC无效bug
    Image: fix Esc can never close the preview at the second time #1… ElemeFE/element#19027
    [Image]: Fix page cannot scroll up and down when previewSrcList is empty ElemeFE/element#18906
  3. fix undesired overflow: scroll style
    修复点击没有预览功能的图片后body上加了overflow: scroll的bug
    Image: don't show image-viewer when preview is false ElemeFE/element#18967
  4. fix a race condition if src changes too frequently
    修复如果用户点击过快事件触发混乱的bug
    Image: fix a race condition if src changes too frequently ElemeFE/element#18837
  5. add close-on-click-modal prop
    添加点击遮罩层关闭预览的功能
    image: 增加 close-on-click-modal props 控制点击mask 关闭预览图的功能 ElemeFE/element#18947

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow Element's contributing guide (中文 | English | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer relative issues for you PR.

1.  set preview `:initial-index` to `0` if src is not in previewSrcList
ElemeFE#18871
and also fix preview example
2. fix ESC won't close preview for the second time
ElemeFE#19027
ElemeFE#18906
3. fix undesired `overflow: scroll` style
ElemeFE#18967
4. fix a race condition if src changes too frequently
ElemeFE#18837
5. add `close-on-click-modal` prop
ElemeFE#18947
@@ -216,7 +202,7 @@ export default {
},
handleImgError(e) {
this.loading = false;
e.target.alt = '加载失败';
e.target.alt = this.t('el.image.error');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.t ??

this.loading = true;
}
});
}
},
methods: {
hide() {
this.deviceSupportUninstall();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个方法在 destroyed 调用了,整个组件是用 v-if 管理的
https://github.com/EOITek/element/pull/18/files#diff-4070c65e02876a1516baf9e0f17ebc22R18

@@ -216,7 +202,7 @@ export default {
},
handleImgError(e) {
this.loading = false;
e.target.alt = '加载失败';
e.target.alt = this.t('el.image.error');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.t 是element做国际化使用的方法,会按照名字查找对应的翻译

await wait(1000);
expect($wrapper.style.display).to.equal('none');
await wait(600);
expect(vm.$el.querySelector('.el-image-viewer__wrapper')).to.be.null;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.to.be.null; 这是什么操作 没看懂

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to.be.null 就是 === null,这是单元测试的语法

await wait(1000);
expect($wrapper.style.display).to.equal('none');
await wait(600);
expect(vm.$el.querySelector('.el-image-viewer__wrapper')).to.be.null;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因为v-if掉了所以就是null了

@ZJL8 ZJL8 merged commit 232c36f into EOITek:dev Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants