开发者

Speeding up running jquery animation

开发者 https://www.devze.com 2023-04-03 16:53 出处:网络
Similar questions have been asked on stackoverflow before, but I haven\'t found a single satisfying answer.

Similar questions have been asked on stackoverflow before, but I haven't found a single satisfying answer.

I want to speed up (or slow down for that matter) a running jquery animation. I have a animation with a long duration that slides some text past the user (think film credits), but in case the user wants to not read the text he can click on the text, in this moment the text's movement should speed up to make way for the content that follows thereafter.

I see two approaches here: I. Somehow alter the duration of the currently running animation开发者_C百科, thus finishing the animation faster, even though I'm not entirely sure how to go abouT this.

II. Stop the animation and start a new, faster one. The problem here is though that by stoping the animation I don't get a continuos, smooth animation, but one slow one, a stop and then a fast one, which is not really what I'm looking for either.

Any help with this will be greatly appreciated!


It sounds like you want more control over your animations than the convenience methods of jQuery probably were designed for. To get full control, you could move your text directly yourself.

function tick() {
    // Move your text a bit here. Move more to make it go faster.
}
setInterval(tick, 1000/30);
0

精彩评论

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