JavaScript function is only working the first time I call it? -
I was wondering if you can help me troubleshoot problems. Hopefully you will not need a document to use the graphics package to identify this problem, but if this happens, go here.
I have the following block of code
window.setInterval (function () {mycirc.transform ("t1,1");}, 500); Definitely call the function mycirc.transform ("t1,1") every half-second that function will be mycirc Each unit should translate the x and y coordinate (see Element.transform (see [tstr]). However, when I check my page, mycirc is translated once and there is no effect of the call after it. I've used console.log (...) to test and make sure: window.setInterval (function () {var bb = mycirc .getBBox (); console log ("before conversion:" + bb.x + "," + bb.y "); mycirc.transform (" t1,1 "); var bb = mycirc.getBBox (); console.log ("After coord conversion:" + bb.x + "," + bb.y);}, 500); Courses before change: 120.98508107696858,106 jsfunctions.js: 411 cord after transformation: 121.98508107696858, 107 jsfunctions.js: 414 courses before conversion: yields 121.98508107696858,107 jsfunctions.js: 411 cord after transformation: 121.98508107696858 , 107 jsfunctions.js: 411
etc.
Why can any idea?
(I used the source code for the graphics package , But it is ineligible due to some white space.)
Your code < / p>
mycirc.transform ("t1,1"); is not related to the current state. It just changes from the original state to t1,1 and then from t1,1 to t1,1 etc. You should calculate the change every time.
Edit : So it will need a global variable, every time increments like this: var xyPos = 1; window.setInterval (function () {mycirc.transform ("t" + xyPos + "," + xyPos); xyPos ++;}, 500);
Comments
Post a Comment