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

[Feature Request] ImagePreview image slot 也支持长图适应 #12656

Closed
wuchaoxin opened this issue Mar 6, 2024 · 2 comments · Fixed by #12740
Closed

[Feature Request] ImagePreview image slot 也支持长图适应 #12656

wuchaoxin opened this issue Mar 6, 2024 · 2 comments · Fixed by #12740

Comments

@wuchaoxin
Copy link

wuchaoxin commented Mar 6, 2024

这个功能解决了什么问题?

目前如果 ImagePreview 使用了 image slot,发现并不能适应长图。翻开代码后,slot 下不太好判断图片在哪,所以并没有绑定 onLoad 事件和 style、class。能不能将 onLoad 以及 style 放入 slot 的参数中,让开发者手动绑定到图片,以适应长图。

你期望的 API 是什么样子的?

大概类似如此:

{
        default: () => [slots.image ? _createVNode("div", {
          "class": bem("image-wrap")
        }, [slots.image({
          src: props.src,
          onLoad: onLoad,
          style: imageStyle.value
        })]) : _createVNode(Image, {
          "ref": imageRef,
          "src": props.src,
          "fit": "contain",
          "class": bem("image", {
            vertical: vertical.value
          }),
          "style": imageStyle.value,
          "onLoad": onLoad
        }, imageSlots)]
}
<template #image="{ src, onLoad, style }">
      <video
        v-if="judgeMediaType(src) === MEDIA_TYPE.VIDEO"
        style="width: 100%"
        :ref="addELRef"
        controls
        playsinline
      >
        <source :src="src" />
      </video>
      <img
        v-else
        :src="src"
        :ref="addELRef"
        :onLoad="onLoad"
        :style="
          Object.assign(
            {
              display: 'block',
              width: '100%',
              height: '100%',
              objectFix: 'contain',
            },
            style
          )
        "
      />
</template>
@wuchaoxin
Copy link
Author

顺便开放一下 longImageRatio 的修改

Copy link

github-actions bot commented Mar 9, 2024

Hello @wuchaoxin. We totally like your proposal/feedback, welcome to send us a Pull Request for it. Please send your Pull Request to main branch, provide changelog/TypeScript/documentation/test cases if needed and make sure CI passed, we will review it soon. We appreciate your effort in advance and looking forward to your contribution!

你好 @wuchaoxin,我们完全同意你的提议/反馈,欢迎直接在此仓库 创建一个 Pull Request 来解决这个问题。请将 Pull Request 发到 main 分支,提供改动所需相应的 changelog、TypeScript 定义、测试用例、文档等,并确保 CI 通过,我们会尽快进行 Review,提前感谢和期待你的贡献。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants