开发者

MooTools - Prevent events while other events are running

I've been trying to create a slide show, here is my attempt:

http://jsfiddle.net/paulmason411/fNfKk/

It's working quite well, although if you click the continue or previous button really quick the slides don't line up.

Can I disable the next click开发者_高级运维 listener while the tween is in progress?

any help would be great, thanks!


not very veratile code, why don't you write a class? seems messy to deal with your variables this way.

anyway, several ways to tackle this.

easiest to make it work with your code without refactoring: http://jsfiddle.net/dimitar/fNfKk/2/

the idea is to have a scoped variable moving which gets set through the tween's onStart and onComplete events. the left/right slides then check if moving and if so, return w/o doing anything.

way 2: don't tween between 'current position, current position + width' as that is what causes your issues at the moment - if you click it midway, it will lose 'frame' er... focus (i.e. frames won't be centered)

instead, calculate how much each step is and keep a global scrollto var - then each previous/next should up/reduce the scrolltoval and fire a tween to it, eg el.tween("left", scrollto);. combine that with link: 'cancel' on the tween options and you can get fast-forward for the impatient.

good luck.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜