[jQuery] continuous action while mouseover

[jQuery] continuous action while mouseover


Hi friends,

i was wondering: how can i trigger an action while the mouse stays on a specific area of the screen?

i tried the following code: it works ONCE (when the mouseover event is triggered) but not continuously, while the mouse i over my "active" zone.

var centerX = $('#datascape').width()/2;
stepX = 240;
var $datascapeViewport = $('#ds-viewport');
$datascapeViewport.css({position: 'relative',left: 0+'px'})
.bind('mouseover',function(e){
    var minX = $(this).width();
    minX=-minX;
    var maxX = 0;
    var newLeft = 0;
    var Position = $(this).offset();
    if (e.pageX >= centerX) {
        newLeft = Position.left-stepX;
    } else
    {
        newLeft = parseInt(Position.left) + stepX;
    }
    //alert("\nposition.left="+Position.left +"\nnewLeft="+newLeft+"\nstepX="+stepX);
    newLeft = -newLeft;
    if ((newLeft<maxX) && (newLeft>minX)) {
    $(this).animate({left: newLeft+'px'},1000);
    }
});
just for background, i'm trying to have a very wide image scroll horizontally according to the mouse position on the X axis, center being no scroll, left position meaning scroll image right, and invertedly.
Thanks for your insight!
Alexandre
Ce message Envoi est certifié sans virus connu.
Analyse effectuée par AVG.
Version: 7.5.488 / Base de données virus: 269.14.13/1074 - Date: 16/10/2007 14:14