Hello,
I load 5 svg in 5 <embed> and a JS is called in the <body onload="()"> of my HTML page. The JS, for each <embed> (embeds[i]), change the currentScale and currentTranslate values.
The problem is that the transforms are applied for all the SVG except one, and it's never the same !!! and sometimes all the svg are changed...
JS problem ?
I've tried to set some timeout but it's not the solution.
Thanks
Hi Flo
Can you post you code?
Hello,
I load 5 svg in 5 <embed> and a JS is called in the <body onload="()"> of my HTML page. The JS, for each <embed> (embeds[i]), change the currentScale and currentTranslate values.
The problem is that the transforms are applied for all the SVG except one, and it's never the same !!! and sometimes all the svg are changed...
JS problem ?
I've tried to set some timeout but it's not the solution.
Thanks
function minimizeMspCard(){
var i = 0;
var cx = null;
while (i < document.embeds.length){
SVGDocument=document.embeds[i].getSVGDocument();
SVGRoot = SVGDocument.firstChild();
if (cx == null) {
var lastPoint = SVGRoot.getElementById("lastPoint");
cx = lastPoint.getAttribute("cx");
}
if (zoomer(SVGRoot,0.9)){
if (paner(SVGRoot, -cx+275 ,0))
i++;
}
}
}
function zoomer(SVGRoot, k){
var old_taille=SVGRoot.currentScale;
new_taille=old_taille*k;
SVGRoot.currentScale=new_taille;
return true;
}
function paner(SVGRoot, x, y){
SVGRoot.currentTranslate.x = x;
SVGRoot.currentTranslate.y = y;
return true;
}
Hi Flo
I can't see anything wrong with your code. The only part that is confusing to me, is the if around i++...can you explain it to me? If you aren't increasing i, the while loop won't check all the svg documents...
Regards,
function minimizeMspCard(){
var i = 0;
var cx = null;
while (i < document.embeds.length){
SVGDocument=document.embeds[i].getSVGDocument();
SVGRoot = SVGDocument.firstChild();
if (cx == null) {
var lastPoint = SVGRoot.getElementById("lastPoint");
cx = lastPoint.getAttribute("cx");
}
if (zoomer(SVGRoot,0.9)){
if (paner(SVGRoot, -cx+275 ,0))
i++;
}
}
}
function zoomer(SVGRoot, k){
var old_taille=SVGRoot.currentScale;
new_taille=old_taille*k;
SVGRoot.currentScale=new_taille;
return true;
}
function paner(SVGRoot, x, y){
SVGRoot.currentTranslate.x = x;
SVGRoot.currentTranslate.y = y;
return true;
}
Hi Hacc
The if around i++ were used to test some things, but i have tried with a simplier code like this :
function minimizeMspCard(){
var i = 0;
var cx = null;
while (i < document.embeds.length){
SVGDocument=document.embeds[i].getSVGDocument();
SVGRoot = SVGDocument.firstChild();
if (cx == null) {
var lastPoint = SVGRoot.getElementById("lastPoint");
cx = lastPoint.getAttribute("cx");
}
zoomer(SVGRoot,0.9);
paner(SVGRoot, -cx+275 ,0);
i++;
}
}
and it's still doesn't work...i do not know why the process is not applied to all the SVG ???
Hi Flo
Is it possible to email me all your code, so that I can test in on my side?
My email address is cahayter@yahoo.com