0

I was researching a strange behaviour in IE11 and came across this thread with the exact problem, but for IE9:

SVG resizing in IE9

I've got an inline SVG element inside a div, which scales to fit the browser window. When the browser is resized, the SVG image resizes with it, so that all the image is visible, and it keeps the same proportions.*

However, in IE9, the image is much smaller, and doesn't resize. Taking off the viewBox scales the image to the full size, which is too big, and it still doesn't resize.

The problem can be seen in this jsfiddle where the resizing does not work as expected in IE9 nor IE11.

<div id="outer">
<svg viewBox="0 0 700 1000"  xmlns=http://www.w3.org/2000/svg>
        <g transform="rotate(90, 350, 350)" id="pitch-rotated">
            <title>Pitch</title>
            <path d="m0,0l1000,0l0,700l-1000,0l0,-700z" stroke-width="5" stroke="#fff" fill="#008800" id="perimiter"/>
            <line id="centre-line" y2="700" x2="500" y1="0" x1="500" stroke-width="5" stroke="#ffffff" fill="none"/>
            <path id="penalty-box-home" fill="none" stroke="#fff" stroke-width="5" d="m0,148.5l165,0l0,403l-165,0l0,-403z"/>
            <path id="six-yard-box-home" fill="none" stroke="#fff" stroke-width="5" d="m0,258.5l55,0l0,183l-55,0l0,-183z"/>
            <path d="m1000,148.5l-165,0l0,403l165,0l0,-403z" stroke-width="5" stroke="#fff" fill="none" id="penalty-box-away"/>
            <path d="m1000,258.5l-55,0l0,183l55,0l0,-183z" stroke-width="5" stroke="#fff" fill="none" id="six-yard-box-away"/>
            <circle fill="none" stroke="#ffffff" stroke-width="5" cx="500" cy="350" r="95" id="centre-circle"/>
            <circle fill="none" stroke="#ffffff" stroke-width="10" cx="500" cy="350" r="1" id="centre-spot"/>
            <circle fill="none" stroke="#ffffff" stroke-width="7" cx="110" cy="350" r="1" id="penalty-spot-home"/>
            <circle fill="none" stroke="#ffffff" stroke-width="7" cx="890" cy="350" r="1" id="penalty-spot-away"/>
            <path d="m165,277.5a91,91 1 0 10,145" stroke="#ffffff" stroke-width="5" fill="none" id="penalty-curve-home"/>
            <path d="m835,277.5a91,91 0 0 00,145" stroke="#ffffff" stroke-width="5" fill="none" id="penalty-curve-away"/>
            <path d="m0,10a7.5,7.5 0 0 010,-10" stroke="#ffffff" stroke-width="5" fill="none" id="corner-home-left"/>
            <path d="m0,690a7.5,7.5 0 0 110,10" stroke="#ffffff" stroke-width="5" fill="none" id="corner-home-right"/>
            <path d="m1000,10a7.5,7.5 0 0 1-10,-10" stroke="#ffffff" stroke-width="5" fill="none" id="corner-away-left"/>
            <path d="m1000,690a7.5,7.5 0 0 0-10,10" stroke="#ffffff" stroke-width="5" fill="none" id="corner-away-right"/>
        </g>
</svg>      

So my question is, is there still no non-JS way of solving this, even in IE11?

Community
  • 1
  • 1
JohanR
  • 103
  • 2
  • 7
  • Is this an issue in IE11 since the previous question related to IE9? If so, please clarify what **your** issue is. – Paulie_D Aug 11 '14 at 13:28
  • Yes, my issue is the same, unresolved in IE9, and still not solved in IE11 afaik. I want to know if anyone has solved it for IE11 in these 2 years. Updated question to clarify. – JohanR Aug 11 '14 at 14:13

1 Answers1

0

Encountered similar problems with one of my clients. So, the checklist:-

  1. Is the window.onresize triggering?
  2. Are you able to read the new window.innerHeight and window.innerWidth?

What I did was write a zoom slider for SVG. With window.addEventListener("resize", .....) code (thank you SO), read the new height and width values, calculate the correct Zoom. If .onresize doesn't trigger (happen occassionally on every browsers, out of our control), they can use the slider to fix it.

Sideline: Out of curiosity, this looks like a soccer game simulation?

Community
  • 1
  • 1
Alvin K.
  • 4,329
  • 20
  • 25
  • Note: I'll be all ears if someone can solve it the **non-JS** way. – Alvin K. Aug 11 '14 at 17:54
  • Thank you, we're planning on using a js way to deal with this, but would very much rather find a non-JS way. The JSfiddle was re-used from the previous asker of this question for IE9, so that is not mine. We're making a online music notation reader :-) – JohanR Aug 13 '14 at 09:35