jstoudt / enscroll

A jQuery plugin for custom scrollbars
http://enscrollplugin.com
Other
73 stars 46 forks source link

Scroll Easing #20

Closed maimairel closed 10 years ago

maimairel commented 10 years ago

Hi, this is a great plugin!

Is there any chance to implement easing functionality?

jstoudt commented 10 years ago

Hi @maimairel Appreciate the compliment!

Right now the plugin is only designed to use scroll easing for touch events. My thought was that since no desktop operating systems used scroll easing with the mouse wheel, it may be a jarring user experience.

Do you have an example of where the functionality you're looking for may already exist. If I can see it in action I may be persuaded to implement such a feature.

maimairel commented 10 years ago

Yes, here are some of them:

http://manos.malihu.gr/tuts/jquery_custom_scrollbar.html http://areaaperta.com/nicescroll/

That kind of scrolling momentum is right now very popular on websites. Both of them are to bloated for what I need so I'm using yours :)

jstoudt commented 10 years ago

Got it. Let me look into it and see what I can come up with.

maimairel commented 10 years ago

Hi, any news on this?

It can be done by just animating the scrollTop/scrollLeft, but that won't work smoothly with jQuery.animate(). We need a more robust animation engine (I saw examples using GSAP TweenMax plugin that works superb, but we can't use that as it's not free). The one here http://manos.malihu.gr/tuts/jquery_custom_scrollbar.html uses its own Tween engine. I tried modifying your code with his, and got the momentum scrolling to work partially, but the code needs a lot of improvements so I'll leave that to the author :)

Thanks!

jstoudt commented 10 years ago

@maimairel I've written the code necessary for the animation and rewrote the key handlers and mouse wheel handler to use the new animation code. I still need to rewrite the handle dragging event handlers to use the animation code. I also need to do some more testing before I can safely release it. As soon as I get the next handler rewritten, I'll push the branch so you can grab it.

maimairel commented 10 years ago

Thanks a lot for the quick implementation, I'll be looking forward to it!

jstoudt commented 10 years ago

I just released enscroll 0.5.0, complete with scroll easing and some other bug fixes. Let me know what you think.

maimairel commented 10 years ago

Just perfect! Thanks a lot for the update :)

maimairel commented 10 years ago

One thing though, what's the unit of the easingDuration? It seems like 60 = 600ms, 600 = 6s. Just a zero too much :)

jstoudt commented 10 years ago

The easingDuration parameter is actually the number of frames of the animation. So, 60 frames / 60fps = 1s. But, you are right to question this. It seems less than straightforward as developer to expect this unit of measure. And, it can be easily corrected with just a little math to convert milliseconds to frames. I'll open a new issue to correct this problem.

jstoudt commented 10 years ago

Issue #22 has been created to deal with easingDuration parameter.