I'm still playing around with D3 and drawing SVG elements and I decided I wanted to try making a graphic that can scale based on track pad (two-finger touch expand) and maybe a shift + scroll wheel move, but leave everything else as is. I've noticed that the entire page scales when I try these moves. Unfortunately, I have no idea how to make that work.
$('#target').html('<svg height="200" width="200"><rect width="100" height="100" x="50" y="50" fill="red" /></svg>');
#top, #bottom {
position: fixed;
left: 0;
background-color: #000;
height: 25px;
width: 100%;
}
#target {
margin: 25px 0;
}
#top {
top: 0;
}
#bottom {
bottom: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="top"></div>
<div id="target"></div>
<div id="bottom"></div>
So, here are the rules I've come up with:
- The DIVs at the top and bottom cannot scale. The must stay at scale factor 1.
- Changing the browser dimensions will not change the scale of the SVG.
- Using any method for scaling (pinch zoom, shift + scroll wheel, etc) should only effect the SVG.
- Scaling the SVG so that the drawn rectangle is off of the viewport should not prevent us from scrolling or dragging to see the rest of the SVG.
Does anyone know how to make something like this work? Perhaps there is a tutorial someplace that explains this?
Thanks!
PS - I'm not apposed to using an iframe if that helps solve this.