What is the correct syntax for providing the viewBox attribute of an svg element using predefined values? I have it:
var mySvg=Snap("#mySvg"); var worldMap=mySvg.select("#worldMap");
when i tried this:
worldMap.attr({viewBox:"760, 455, 132, 78"});
It works great. However, when I tried to use the options:
var x=760; var y=455; var wi=132; var hi=78; worldMap.attr({viewBox:"x, y, wi, hi");
nothing happened why? I believe the problem is finding the right syntax. I also tried:
worldMap.attr({viewBox:x, y, wi, hi); worldMap.attr({viewBox:{x, y, wi, hi}); worldMap.attr({viewBox:(x, y, wi, hi)); worldMap.attr({viewBox:[x, y, wi, hi]);
nothing works yet ... any suggestion?
source share