Ah ha...I see what you are trying to do. I don't think my solution will work for you, because you need to dynamically send new parameters to the function every time the mouse moves. In my solution, the parameters are fixed in the function; once it is bound as the event handler to the datascapeViewport, it will not accept any more parameter input.

Probably what is happening is that setInterval is running every 20 ms, but there is no movement because it is not accepting the new position when you move the mouse. You might want to do some Firebug console logging to confirm that.

What you can do is set up a global object to contain the settings and parameter values, and reference that global object in your moveDatascape function, rather than trying to pass in the parameters in the setInterval call. Then on mousemove you can update the mouseX value of that global object, and your function will pick up the new value on the next iteration of setInterval.

-- Josh



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



thanks for hanging on Josh _ this is really driving me nuts. i wrote this code in actionscript2 4 months ago and it worked well (see it in action here (wait that all images be loaded, click on the weird image: http://www.thor.be/creation.php?id=3) then move around your mouse, and you 'll see you can control the horiz scrolling proportionally to your mouse position.

So, i managed to adapt your code sample and i don't get any errors anymore _ but the result is the same:

the setIntervalled function happens only once.

you can see it here: http://m2.lab-au.com/proto_metalab2_datascape.htm

should you wish to check my code: http://m2.lab-au.com/_js/frontend/datascape.js


thank you,

alex

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


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


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