richardscarrott / jquery-ui-carousel

jQuery RS Carousel is a responsive and touch-enabled carousel written on top of jQuery and the jQuery UI Widget Factory providing a full and familiar API in less than 2.6kB minified and gzipped.
http://richardscarrott.github.io/jquery-ui-carousel/
192 stars 56 forks source link

Mousewheel #40

Closed scruffian closed 12 years ago

scruffian commented 12 years ago

It would be great to add mouse wheel integration into this. If no one else has the opportunity I'll try and get to it, but it will take a while!

richardscarrott commented 12 years ago

I wrote an extension to the carousel a while ago to add this functionality so scrolling the carousel with the mousewheel would update the internal state and consequentially update the UI.

I'll dig it out and clean it up when I get a chance and hopefully that'll be what you're looking for.

scruffian commented 12 years ago

that sounds perfect. i am using this carousel alongside jcarousel lite at the moment because sometimes we need the mousewheel, so to just use yours will be a great help!

richardscarrott commented 12 years ago

I just took a look at jCarousel lite's mousewheel demo and it turns out the extension I wrote a while ago isn't the same kind of thing as it doesn't 'snap' to each page, it just scrolls like a standard overflow: scroll div but updates the internal state and UI.

If you just want the snap to behavior then I'd try something like this:

$('#rs-carousel').carousel({
    create: function () {
        var el = $(this),
            runner = el.find('.rs-carousel-runner'),
            mask = el.find('.rs-carousel-mask'),
            method;

        mask.mousewheel(function (e, delta) {
            e.preventDefault();
            method = delta > 0 ? 'prev' : 'next'
            if (!runner.is(':animated')) {
                el.carousel(method);
            }
        });
    }
});
scruffian commented 12 years ago

Thanks! I'll give it a go when I get a chance and let you know how i get on...

punkerben commented 11 years ago

I have a ui-touchCarousel version and could not get the mousewheel to work, is there another syntax that works for the touch extension?

richardscarrott commented 11 years ago

I just tested and the above code works okay with the touch extension. Are you sure you're using the latest version of the carousel 1.0.1 and including the mousewheel plugin

punkerben commented 11 years ago

I was using the scripts you have in this demo http://www.richardscarrott.co.uk/assets/javascript/jquery/ui-carousel-touch/demo.html

I updated to ui.carousel v1.0.1 and it seems works, just need to test in all browser/iOS to be sure.

richardscarrott commented 11 years ago

Yeah I need to take that link down as it was an early experiment that was never actually released, the latest version offers up all the touch functionality and is better tested.