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

Persist CSS details/data for cropped image when tabs are switched using MudTab #208

Closed
JunaidSultan20 opened this issue Sep 6, 2023 · 2 comments
Labels
question Further information is requested

Comments

@JunaidSultan20
Copy link

Describe the bug
After cropping the original image, the newly cropped image is displayed on the UI. However, when I switch between the tabs, the CSS details for the cropped image are reset to 0px. The data or details persist for the original tab where the image is cropped but are lost when the tab is switched. Also, can we send multiple CSS classes? If so, how can be they assigned either using an array or comma separated string.

To Reproduce
Steps to reproduce the behavior:

  1. Upload the original image.
  2. Select the desired area of the image and crop it.
  3. Observe that the cropped image is correctly displayed in the UI.
  4. Switch to another tab and observe the images are not displayed.
  5. Now switch back to the original tab and observe that the cropped image is visible.

Expected behavior
The copped image should be displayed when tabs are switched, and the style and CSS details should persist. Whenever I switch the tabs the cropped image should persist/visible on all tabs.

Screenshots
Tab1
Tab2

Code Snippet
Options = new Options() { AspectRatio = CropperWindowWidth / CropperWindowHeight, ViewMode = ViewMode.Vm0, CorrelationId = Guid.NewGuid().ToString(), Preview = PreviewClass, AutoCrop = true, DragMode = "move" };

Desktop (please complete the following information):

  • OS: [Windows 10]
  • Browser [Edge]
  • Version [116.0.1938.69]
@JunaidSultan20
Copy link
Author

My findings are that the cropped image is shown in the preview div that is available in the DOM. If that preview is not visible/available in the current tab or DOM, the image is not rendered.

@MaxymGorn MaxymGorn added the question Further information is requested label Sep 6, 2023
@MaxymGorn
Copy link
Member

MaxymGorn commented Sep 6, 2023

Hi @JunaidSultan20 . I you wanna persist image cropper preview after destroying cropper component(case when you change tabs) you need get image from preview or using GetCroppedCanvasDataURLAsync method cropper component for saving image as base64 and use it. Example getting image:

string croppedCanvasDataURL = await CropperComponent!.GetCroppedCanvasDataURLAsync(getCroppedCanvasOptions);

Moreover, if you need a fully persist cropper component metadata with image (not preview image), you can go through this conversation:
#182

Css styles can be viewed on the demo site or on the site of the original cropper.js library, I think this is quite enough. You can setup whatever!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants