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

Not hiding overflow:hidden data #349

Closed
ankur1708 opened this issue Mar 16, 2014 · 17 comments
Closed

Not hiding overflow:hidden data #349

ankur1708 opened this issue Mar 16, 2014 · 17 comments

Comments

@ankur1708
Copy link

I am using html2canvas to make 1 image out of 3-4 images. All these images can be zoomed for which i am using jquery zoom. There is one parent div holding all these images.
Overflow is hidden for all these images so that user can set it as per his wish.
Without zooming, on Html2Canvas, i am getting a perfect canvas element. But when any image is zoomed, and then i try HTML2Canvas, the hidden content is shown in canvas created. Is there a solution for this which i may not aware of.
My functionality is similar to http://www.fotor.com/features/collage.html.
Thanks in Advance.

@brcontainer
Copy link
Contributor

Try this #60 or this #242

@ankur1708
Copy link
Author

@brcontainer : I've seen that already. My case is actually li'l complicated.
Just like fotor collage (link provided above) i want user to zoom an image and then create one image out of all the images.
Sample: Square div containg 4 images each in one quadrant. Each quadrant has css property of overflow hidden. I want a screenshot of that div.
Now if any image is zoomed, then in the screenshot the overflow-hidden part is getting rendered within the boundary of parent Square div. This cause overlapping in the zoomed image is at stacked over other images.
Let me know if you need more details. Thanks.

@brcontainer
Copy link
Contributor

You mean that your problem is with overlapping images instead of overflow?

@ankur1708
Copy link
Author

It's overlapping because of overflow. Here are some screenshots to understand it better.
Here is the screenshot containing a div in which 3 images are there (blue dress, white top and green pants) with no zoom. http://bit.ly/1fNjKzW . Using html2canvas on this div giving perfect canvas. Please note that every div containing image has overflow hidden in css

Here is the screenshot of div in which green pant is zoomed. http://bit.ly/1ibtDXL
And here is the canvas generated by using html2canvas on the previous image. http://bit.ly/1e8190r

See that in the image 3, the hidden overflow of green pant is rendered, which cause overlapping of images.
Let me know if more data is needed. Thanks.

@brcontainer
Copy link
Contributor

Got it, so you're not just taking a picture of the zoom, but the entire frame (included small images and zoomed image).

What do you want to take a picture of the box, including the small photo.

Place an online sample of your problem, not the fault seems to be in html2canvas, but in your html/css.

@ankur1708
Copy link
Author

Here is the sample of html i am using http://pastebin.com/78TJLdXL. I am calling html2canvas on 'sets_template' class.
For zooming, I am using panzoon jquery plugin.

@brcontainer
Copy link
Contributor

Please, post a working example.

@ankur1708
Copy link
Author

Here is fiddle @brcontainer : http://jsfiddle.net/LCVSk/10/
The third image is zoomed by index of 2 (directly by setting matrix transfrom in html). Clicking on publish set button create canvas with overlapped image.
If the zoom level is 1, then no issue is observed.
Let me know if anything else is required. Thanks.

@brcontainer
Copy link
Contributor

Note: Your code does not work in Firefox, partially works in google chrome.

html2canvas have a bug regarding css property -webkit-transform: matrix(...); and have a bug with z-index (with images).

Your code is relatively simple and has easier alternatives to solve this problem that do not use "css3", if you css2+javascript you will get surely create a better alternative.

@ankur1708
Copy link
Author

Yes, images are not loading on firefox right now, but working perfect on chrome.
-webkit-transform is for webkit based browsers, for firefox, transform css property is being used at my side. My bad i pasted the code from chrome console.
I will try to use css2 + js and see if that fixes the issues. Thanks for your time @brcontainer

@ankur1708
Copy link
Author

@brcontainer : I did some testing with various browsers and it looks like that probably, there is a bug with transform css property.
Here is the working sample for firefox: http://jsfiddle.net/LCVSk/14/ .
Here is for chrome: http://jsfiddle.net/LCVSk/13/

The issue i think is bounds/clip computation. Let me know either way. Thanks.

@brcontainer
Copy link
Contributor

was what I said in last comment:

html2canvas have a bug regarding css property -webkit-transform: matrix(...); and have a bug with z-index (with images).

For this reason I said that is better css2+javascript

Try this lib:
http://mark-rolich.github.io/Magnifier.js/

Works in Chrome, Firefox, Safari, IE 7, 8, 9 & 10, in other words, this library does not need CSS3

@niklasvh
Copy link
Owner

Is this still an issue with v1.0.0? If so, could you please share an example on jsfiddle.

@no-response
Copy link

no-response bot commented Dec 12, 2017

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@Lxiaozhuang
Copy link

请问 这个解决了么 ? 我现在也遇到了这个问题 scale放大后的图片最后在html2canvas生成图片后 隐藏的部分都显示出来了

@brcontainer
Copy link
Contributor

@Lxiaozhuang In html2canvas-0.4.1 or in html2canvas-1.0?

@nishantgupta11
Copy link

-> Add CSS overflow-y: scroll; to HTML element pdfHTML
-> Add attribute width & windowWidth to html2canvas method, which should be equal to width of pdfHTML Div

html2canvas(document.querySelector(".pdfHTML"), {
    width: 1350, windowWidth: 1350
}).then(canvas => {
    base64stringpdf = canvas.toDataURL("image/jpeg");
});

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

No branches or pull requests

5 participants