How do I manipulate the scroll bars so that a div with content that changes size is showing the same
Posted
by Shaun
on Stack Overflow
See other posts from Stack Overflow
or by Shaun
Published on 2010-03-24T15:41:10Z
Indexed on
2010/03/24
15:43 UTC
Read the original article
Hit count: 350
What I have is a div, for example is 800*800 px, and inside of this div is a SVG image, which can fit in the div but also can get very large, say 5000*5000 px, and I need to manipulate the scrollbars so that when the SVG has changed size the scrollbars adjust so that you are seeing the same center of your 'viewport' that you were seeing before.
The reason I use 'viewport' is because I have seen exactly what I am trying to achieve done in WPF. Initially it sets the center as the center of the SVG so that when the SVG gets larger then the container the scrollbars automatically scroll to show the center of the SVG. If the user scrolls the 'viewports' center is updated and any changes in size now center there.
I need this to be cross-browser compliant and done only with javascript.
However I really don't care what container the SVG is being bounded by.
© Stack Overflow or respective owner