nckprsn / scrollme

A jQuery plugin for adding simple scrolling effects to web pages.
1.47k stars 319 forks source link

Callback function #12

Open camoix opened 10 years ago

camoix commented 10 years ago

Hi, thanks for this awesome plugin.

Please consider the possibility to add callback function to each animated item like " data-callback = 'myFunction()' " or the addition of a class when the animation ends like " data-classCallback = '.myClass' " Thanks.

Best regards Xesc.

nckprsn commented 10 years ago

Adding classes before/during/after the span of the animation sounds most feasible - I'll post back here when I've had a chance to look into it properly.

nckprsn commented 10 years ago

Re your email, if you just want to change an image once an animation reaches its end point then you could do this with another animateme element placed over the existing one that fades in as soon as the other animation ends.

camoix commented 10 years ago

Hi Nick, I've been playing with your code and finally I made a modification that it works with the 2 options, adding a class and play a function when the animation is done. I created 2 new tags:

you can see here: http://digitalpoint.es/test/scrollme-master/demo3.htm

It works, but I'm not happy at all with the method that I use to detect the end of an animation. This method looks for the css of each item and when it doesnt have any transformation or grade of opacity determine that the animation has ended and do the stuff. Not good enought but it works for the demo.

I think that the best way to detec the end of the animation is detect if the item position is between the data-from and data-to: if position item > data-from = not started the animation if position item < data-from & > data-to = started the animation if position item < data-to = finish the animation

but I dont know how to do that. What do you think about?

Regards, Xesc