Alexandre, just to clarify:

moveDatascape =
function(el,mouseX,scrollSteps,stageWidth,frameWidth,maxX,minX) {
     return (function() { // rest of function follows
                               }); // close the anonymous function
}

You need the parentheses before and after the anonymous function, that is what creates the closure and "seals in" your parameters, so when the function is finally executed in the setInterval call, the var values that you initially passed in through the parameters are intact.

Also, I think I goofed - this:
myfunc = return moveDatascape('#dsViewport',mouseX,scrollSteps,stageWidth,frameWidth,maxX,minX);

Should be this instead (remove "return")
myfunc = moveDatascape('#dsViewport',mouseX,scrollSteps,stageWidth,frameWidth,maxX,minX);

And, make sure the myfunc declaration is in the document.ready block, just before the setInterval call.

Keep hacking away at it, I think it will work!

-- Josh





----- Original Message ----- From: "Alexandre Plennevaux" <[EMAIL PROTECTED]>
To: <jquery-en@googlegroups.com>
Sent: Thursday, October 18, 2007 2:02 PM
Subject: [jQuery] Re: setInterval not working



hi Josh,

i tried your suggestion but that does not work. all the function parameters get lost somewhere in the cascade of functions...

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Josh Nathanson
Sent: jeudi 18 octobre 2007 18:03
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: setInterval not working


I think you need to do something like this:

myfunc = return
moveDatascape('#dsViewport',mouseX,scrollSteps,stageWidth,frameWidth,maxX,minX);

But, you don't want moveDatascape to actually execute at that point, so you'll need to alter your moveDatascape function a bit:

moveDatascape =
function(el,mouseX,scrollSteps,stageWidth,frameWidth,maxX,minX) {
     return (function() // rest of function follows

Then you can just do:

setInterval(myfunc, 20);

-- Josh



----- Original Message -----
From: Alexandre Plennevaux
To: jquery-en@googlegroups.com
Sent: Thursday, October 18, 2007 10:21 AM
Subject: [jQuery] setInterval not working


hi friends,

can someone tell me what i'm doing wrong:

i'm implementing a list displayed horizontally, that should position itself
according to the user position. if the mouse is in the extreme left, div
should move to the left rapidly, if it is in middle left, it should move
half the speed, etc.

this is my code:  http://m2.lab-au.com/_js/frontend/datascape.js

check this prototype : http://m2.lab-au.com/proto_metalab2_datascape.htm


it appears the function responsible for updating the zone position is only
triggered once, whereas it is launched via a setInterval, so i assumed it
should be triggered every n millisecondds.


Could someone enlighten me?

thanks a lot,

Alexandre Plennevaux - LAb[au] asbl.vzw / MediaRuimte
Lakensestraat/Rue de Laeken 104
B-1000 Brussel-Bruxelles-Brussels
Belgie-Belgique-Belgium
Tel:+32(0)2.219.65.55
Fax:+32(0)2.426.69.86
Mobile:+32(0)476.23.21.42
http://www.lab-au.com
http://www.mediaruimte.be
__________________________________________________________________________
The information in this e-mail is intended only for the addressee named
above.  If you are not that addressee, please note that any disclosure,
distribution or copying of this e-mail is prohibited.
Because e-mail can be electronically altered, the integrity of this
communication cannot be guaranteed.
__________________________________________________________________________



Ce message Envoi est certifié sans virus connu.
Analyse effectuée par AVG.
Version: 7.5.488 / Base de données virus: 269.15.0/1076 - Date: 17/10/2007
19:53

Ce message Envoi est certifié sans virus connu.
Analyse effectuée par AVG.
Version: 7.5.488 / Base de données virus: 269.15.0/1076 - Date: 17/10/2007 19:53


Reply via email to