ryrych / rcarousel

yet another jQuery UI carousel
http://ryrych.github.com/rcarousel/
171 stars 48 forks source link

aotuscroll by 1 on last image select #7

Closed evrim closed 12 years ago

evrim commented 12 years ago

Hi,

I think when user selects the image at the most right, carousel should scroll one to show another one. I think this should be valid for the image on the most left.

Is it possible to implement such a feature? Are you busy?

Kind regards, evrim.

ryrych commented 12 years ago

Actually you can do this yourself. The code below is just a bit modified version of ‘margin between elements’ example.

jQuery(function($) { var _currentPage, _visibleElements = 3, $carousel = $( "#carousel" );

            $( "#carousel  img" ).click(function() {
                _currentPage = $carousel.rcarousel( "getCurrentPage" );

                if ( $(this).index() + 1 % _visibleElements === 3 ) {
                    $carousel.rcarousel( "next" );
                } else if ( $(this).index() + 1 % _visibleElements === 1 ) {
                    $carousel.rcarousel( "prev" );
                }                   
            })
            $carousel.rcarousel({
                margin: 10,
                visible: _visibleElements,
                step: 1
            });

});

Oh, how do I mark code?

The code could be simplified further, that is it there should be an ‘elementClicked’ event. It used to be. I’ll add it to the next version.

And yes, I am busy as everyone else. You can always hire me to do special things for you. ;)