-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
SVG background image does not render in IE #795
Comments
I suspect this is an issue with IE itself. It seems some SVGs work, others don't. |
That may not be the case .. if you open the SVG directly in IE, it renders fine. Its only through cytoscape that it doesn't render as a background image. Do you have an example of an SVG that does work in IE? |
Please note as noted in another, similar ticket that SVGs are rendered differently in the DOM than in canvas. Cytoscape.js can not change it if IE renders SVGs incorrectly in canvas. You could try with a simple I do not have access to IE, though I suspect the issue is on their side (especially since there is no issue in other browsers). And if so, it would probably make sense for us to file a bug with them. |
Could you check this again please? For me this problem does not only exist in IE but also in Firefox (Chrome works). Normally I have no SVG problems in Firefox. Could this problem be related to Cytoscape.js? |
I verified that this was indeed an IE bug (not surprised). I reported it here : https://connect.microsoft.com/IE/feedbackdetail/view/1161278/canvas-does-not-render-scaled-svg-image If you are inclined, you can verify it here: http://plnkr.co/edit/kEMS7G?p=preview For my case, both Chrome and Firefox (both on Mac) worked fine. |
Thank you very much for your answer. You are right, the gnu.svg example works in Firefox. Strange... So I probably have to check my SVGs. I tried your plnkr.co example. It works great in Chrome. However both Internet Explorer AND Firefox can't draw the second one on my PC... I am using Firefox 36.0.4 on Windows 7. If I click on Draw2 in Firefox the Console outputs "IndexSizeError: Index or size is negative or greater than the allowed amount" (script.js:17:0) |
I tried the plunkr again on Firefox and it doesn't seem to be working. The issue is that clipping the image outside the bounds of the image size doesn't work in both FF and IE, whereas clipping the images inside or outside the bounds of the images size doesn't work in IE at all, but works in FF Consider the drawImage() API (as used in the plunkr): https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage ctx.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight); Case 1: If sx=0 and sWidth <= dWidth Case 2: If sx=0 and sWidth > dWidth Both cases work in Chrome. So in the plunkr drawImage2() for Firefox, I am wondering if cytoscape.js is scaling the image per Case 1 when rendering and if that is causing IE to not render the images at all. @maxkfranz can you confirm? |
Example with gnu.svg: No problem on the latest Firefox. If there's a problem, I don't think it's with Cy.js. Please investigate your SVG file. |
Thanks. I think I found out what the problem with my SVGs is: They have no width and height attributes in the svg element. If I add something like |
By the way: I just found out that IE sometimes renders SVG in Cytoscape.js if you add |
You ought to specify pixels for SVG if you want it to render well in the browser. The size only matters as a relative viewport size for the inner elements. SVG is scalable vector graphics, after all... |
If a node has a SVG background image, it does not render in IE 11. A png does.
SVGs render fine in Chrome, Firefox and Safari.
Here's the plunker: http://plnkr.co/edit/wLuoon?p=preview
The text was updated successfully, but these errors were encountered: