4

I've got a <div> element on page with SVG in it. Sometimes during program execution the size and position of containing div changes. SVG follows the div but doesn't scale along with it, unfortunately. How can I get SVG bigger or smaller when the size of containing element changes?

I use Raphael library for SVG creation and jQuery for events and DOM manipulation.

  • Does this thread help at all? http://stackoverflow.com/questions/644896/how-do-i-scale-a-stubborn-svg-embedded-with-the-object-tag – rpamely Mar 19 '13 at 01:50

1 Answers1

1

You can use setViewBox() http://raphaeljs.com/reference.html#Paper.setViewBox

However, if you use this for scaling there will no longer be a 1:1 unit:pixel scale.

Matt Oates
  • 155
  • 8
  • Last I checked Raphaël still kept the `width` and `height` attributes (prevents auto scaling), so it wasn't enough to just call `setViewBox`. See http://stackoverflow.com/a/11190909/109374 (and comments) for more details. – Erik Dahlström Apr 25 '13 at 08:21