开发者

Execute function while mouse is at certain position

I'm trying to do something like this:

var mouseY = //mouse y-position relative tot some element

while (mouseY > 0 && mouseY < 200){
    //scroll element -5px
}

I want to scroll a certain element up as long as the mouse is within a certain area of an element.

Getting the mouse position and scro开发者_如何转开发lling is not the problem (using scrollTo plugin),

I just can't figure out how to bind this to an event and keep it repeating whil the mouse is in the required area...

Hope someone can point me in the right direction...


After doing the scrolling, set a timer to re-check the mouse state again in, say, 50 milliseconds.

window.setTimeout()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜