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(components): [image-viewer] Add rotate event when rotating images #14138

Merged
merged 3 commits into from
Sep 6, 2023

Conversation

HADB
Copy link
Contributor

@HADB HADB commented Aug 28, 2023

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

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

Description

🤖 Generated by Copilot at 2920ecd

This pull request adds a new rotate event to the Image Viewer component and its documentation. The event allows users to listen for changes in the image rotation and get the current rotation degree.

Related Issue

Fixes #14136.

Explanation of Changes

🤖 Generated by Copilot at 2920ecd

  • Add a new event rotate to the Image Viewer component that is triggered when the user rotates the image and passes the current rotation degree as a parameter (link, link, link)
  • Update the documentation of the component in docs/en-US/component/image.md to include the new event and its parameter (link)
  • Add a validator function for the event parameter in packages/components/image-viewer/src/image-viewer.ts to ensure it is a number (link)
  • Emit the event from the component in packages/components/image-viewer/src/image-viewer.vue whenever the user clicks the clockwise or anticlockwise buttons and pass the updated rotation degree as a parameter (link)

@pull-request-triage
Copy link

👋 @HADB, seems like this is your first time contribution to element-plus.

  • Please make sure that you have read our guidelines and code of conduct before making a contribution.
  • You can comment with /label Components:[component_name] to add a label for which component you are working on.
  • You may join our Discord for staying tuned.

@pull-request-triage pull-request-triage bot added 1st contribution Their very first contribution Needs Review labels Aug 28, 2023
@github-actions
Copy link

Hello @HADB, thank you for contributing to element-plus, please see our guideline to see how to make contribution

@github-actions
Copy link

github-actions bot commented Aug 28, 2023

@HADB
Copy link
Contributor Author

HADB commented Aug 29, 2023

@btea Hi, could you please take a look at this PR when you have time? Any chance of getting it merged?

@github-actions github-actions bot added the CommitMessage::Qualified Qualified commit message label Aug 29, 2023
@btea
Copy link
Collaborator

btea commented Aug 29, 2023

I don't think it would be useful to emit this event, can you elaborate on your rationale?

@HADB
Copy link
Contributor Author

HADB commented Aug 29, 2023

比如说,我有一堆图片,通过 ImageViewer 去做预览,其中有些图片的旋转角度是有问题的,需要调整,那我在预览的时候点了旋转这个操作,我希望能够 emit 出来,这样我可以对这些图片进行旋转的处理。不然这两个旋转按钮就只是用来看,没有实际的意义了。
具体的场景就是我在做一个在浏览器上实现将多张图片合成为PDF的工具,用户上传的图片有些需要做旋转,然后再去合成PDF。目前用的 ImageViewer 去做的大图预览,因为看到刚好有旋转的按钮,所以就想利用这个旋转按钮去做实际的旋转。


For example, let's say I have a bunch of images, and I use ImageViewer to preview them. Some of these images have incorrect rotation angles that need adjustment. When I'm previewing them, I click the rotation button. I hope this action can be emitted so that I can apply rotation adjustments to these specific images. Otherwise, these two rotation buttons would merely be for viewing, without any practical purpose.

The specific scenario is that I'm working on a tool in a web browser that combines multiple images into a PDF. Some of the images uploaded by users require rotation before being included in the PDF. Currently, I'm using ImageViewer for high-resolution previews, and I noticed that there are rotation buttons available. This inspired me to utilize these rotation buttons for actual image rotation.

@github-actions
Copy link

github-actions bot commented Aug 29, 2023

🧪 Playground Preview: https://element-plus.run/?pr=14138
Please comment the example via this playground if needed.

@btea
Copy link
Collaborator

btea commented Aug 29, 2023

Based on your description, I think using the image component for image composition may not be very flexible. Currently image-viewer rotates the image every step 90 degrees, it may not be very convenient for some fine angle adjustments.

According to your actual scenario, I think using a library similar to fabric.js may be more appropriate.🤔

@HADB
Copy link
Contributor Author

HADB commented Aug 29, 2023

Based on your description, I think using the image component for image composition may not be very flexible. Currently image-viewer rotates the image every step 90 degrees, it may not be very convenient for some fine angle adjustments.

According to your actual scenario, I think using a library similar to fabric.js may be more appropriate.🤔

Fabric.js is too heavy for this scenario because I just need the direction of rotation like "clockwise" or "anticlockwise". Or is it more acceptable to emit "clockwise/anticlockwise" directions instead of the degrees?

docs/en-US/component/image.md Outdated Show resolved Hide resolved
Co-authored-by: btea <2356281422@qq.com>
@btea btea enabled auto-merge (squash) September 6, 2023 06:19
@btea btea merged commit 95494b7 into element-plus:dev Sep 6, 2023
10 checks passed
@element-bot element-bot mentioned this pull request Sep 14, 2023
3 tasks
consultation-applio pushed a commit to consultation-applio/element-plus that referenced this pull request Nov 10, 2023
element-plus#14138)

* feat(components): [image-viewer] Add rotate event when rotating images

* Update docs/en-US/component/image.md

Co-authored-by: btea <2356281422@qq.com>

---------

Co-authored-by: btea <2356281422@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants