Ian,
I am using the following code and each item works with temporatily, however, not the way I need it to.
The imgrotate and imgscale actually do rotate and scale the image I click on.
However, If I do a imgscale and then do an imgrotate, the imgscale change was not saved or gets reset and
goes back to the original scale and vice-versa for doing and imgrotate and then an imgscale. There are changes
to the transform in the SVG elements. Again, however, switching the function on the image messes up the original
change. I was expecting to see another attribute added to the svg element (like transform:rotate(45)) or something
like that for the rotate. Any way to get each change to save permanently once the action is performed? Below is my
jQuery / Snap.svg code and what the contents of the SVG looks like before and after a Rotate was done.
$('body').on('change', '#imgopacity, #imgrotate, #imgscale', function() {
switch ($(this).prop('id')) {
case 'imgopacity':
$('#'+currentselecteditem).css('opacity',$("#imgopacity").val());
break;
case 'imgrotate':
var s = Snap("#svgmain");
var sitem = s.select('#'+currentselecteditem);
sitem.transform( 'r'+$("#imgrotate").val(),$('#'+currentselecteditem).attr('x')+($('#'+currentselecteditem).attr('width')/2),$('#'+currentselecteditem).attr('y')+($('#'+currentselecteditem).attr('height')/2));
break;
case 'imgscale':
var s = Snap("#svgmain");
var sitem = s.select('#'+currentselecteditem);
sitem.transform( 's'+$("#imgscale").val()/100);
break;
}
});
/***************************** BEFORE ROTATE ******************************/
<svg id="svgmain" class="" xmlns:xlink="
http://www.w3.org/1999/xlink" xmlns="
http://www.w3.org/2000/svg" style="width: 1187px; height: 681px; bottom: 40px; position: absolute; top: 0px; left: 0px;">
<g id="snapsvg-zpd" transform="matrix(1,0,0,1,0,0)">
<rect id="chartbkgrnd" x="211" y="-154.5" width="765" height="990" style="position: absolute; top: 0px; left: 211px;" fill="#f6e1ff">
<image id="flag_1" class="imgclass" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcMAAAE6CAYAAABqGzkPAAAgAElEQVR4nO3deVhUZ4I/egqKEgUUkX2TpVBWRVHECAZRlKhBVNwQBRMk7iJR0QRxAVyQCG6EsIOo7EsV6fl1T/ft3J47v6f7/p6Znt+d23OfmV9P356Z290zSafTk07y7/f+4VBNSS3nVJ2qU1Dffp7PPx3OOe+pOuf9+r71Li4uLi4gIiJyYp+5OEAhiIiI5PSZiwMUgoiISE6fuUz/Pya1k0RERHPendt3GIZEROTcGIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZER...XJXk6iuYhhSOQgtBotli1bZjQI09LSZC8j0VzFMCRyIHfv3DUYhB4eHmhubpa9fERzFcOQyMFs3LhRLwjT09PR29Mre7mI5jKGIZGD6X/Zj6bGJjQ1NuHRw0fQarSyl4lormMYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR0zMZhklJSURERHNeVFSU8TAkIiJyQp+5OEAhiIiI5PTZ/w9biCLgEd3qIAAAAABJRU5ErkJggg==" preserveAspectRatio="true" x="211" y="-154.5" width="451" height="314" style="opacity: 1; position: absolute; top: 183.5px; left: 368px;" transform="matrix(1,0,0,1,160,315)">
</g>
</svg>
/***************************** AFTER ROTATE ******************************/
<svg id="svgmain" class="" xmlns:xlink="
http://www.w3.org/1999/xlink" xmlns="
http://www.w3.org/2000/svg" style="width: 1187px; height: 681px; bottom: 40px; position: absolute; top: 0px; left: 0px;">
<g id="snapsvg-zpd" transform="matrix(1,0,0,1,0,0)">
<rect id="chartbkgrnd" x="211" y="-154.5" width="765" height="990" style="position: absolute; top: 0px; left: 211px;" fill="#f6e1ff">
<image id="flag_1" class="imgclass" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcMAAAE6CAYAAABqGzkPAAAgAElEQVR4nO3deVhUZ4I/egqKEgUUkX2TpVBWRVHECAZRlKhBVNwQBRMk7iJR0QRxAVyQCG6EsIOo7EsV6fl1T/ft3J47v6f7/p6Znt+d23OfmV9P356Z290zSafTk07y7/f+4VBNSS3nVJ2qU1Dffp7PPx3OOe+pOuf9+r71Li4uLi4gIiJyYp+5OEAhiIiI5PSZiwMUgoiISE6fuUz/Pya1k0RERHPendt3GIZEROTcGIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZEROT0GIZER...XJXk6iuYhhSOQgtBotli1bZjQI09LSZC8j0VzFMCRyIHfv3DUYhB4eHmhubpa9fERzFcOQyMFs3LhRLwjT09PR29Mre7mI5jKGIZGD6X/Zj6bGJjQ1NuHRw0fQarSyl4lormMYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR02MYEhGR0zMZhklJSURERHNeVFSU8TAkIiJyQp+5OEAhiIiI5PTZ/w9biCLgEd3qIAAAAABJRU5ErkJggg==" preserveAspectRatio="true" x="211" y="-154.5" width="451" height="314" style="opacity: 1; position: absolute; top: 183.5px; left: 368px;" transform="matrix(0.7193,0.6947,-0.6947,0.7193,124.2448,-302.5167)">
</g>
</svg>
Thanks to anyone on help with figuring this out.
Kim