Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Keyboard navigation #183

Open
serialbob opened this Issue · 4 comments

3 participants

@serialbob

If you add the keyboard navigation, the script will be perfect !

Thanks

@rob-gordon

Yeah yeah! I second this motion. This is my favorite js gallery that I've ever used- all it lacks is a plugin for keyboard navigation.

@fightingtheboss

This is how I achieved keyboard navigation in Slider 1.1.8. Looks like 2.0 will expose methods to trigger "next" and "previous", which would simplify the case statements down to one elegant line.

      $(document.documentElement).keyup( function(event) {
        var slides = $('#slides .pagination li'),
            current = slides.filter('.current');

        switch( event.keyCode ) {
          case 37: // Left arrow
            if ( slides.filter(':first').is( current ) ) {
              slides.filter(':last').find('a').click();
            } else {
              slides.eq( slides.index(current) - 1 ).find('a').click();
            }
            break;
          case 39: // Right arrow
            if ( slides.filter(':last').is( current ) ) {
              slides.filter(':first').find('a').click();
            } else {
              current.find('+ li').filter(':first').find('a').click();
            }
            break;
        }
      });
@rob-gordon

thanks fightingtheboss. i'm trying to learn js right now so this is doubly helpful

@serialbob

Thank you so mutch. I try now !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.