Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flickity sync and nav hover event #814

Closed
Moorst opened this issue Aug 20, 2018 · 1 comment
Closed

Flickity sync and nav hover event #814

Moorst opened this issue Aug 20, 2018 · 1 comment

Comments

@Moorst
Copy link

Moorst commented Aug 20, 2018

Hi,

I'm looking to change the main carousel on the hover event of a nav item, using flickity-sync.

metafizzy/flickity-sync#8 (comment) essentially covers the functionality I'm after, though of course I'd need a hover event instead of staticClick. Is this available, or is it possible to add a custom hover event?

e.g.

$navCarousel.on( 'hover.flickity', function( event, pointer, cellElement, cellIndex ) {
  if ( cellElement ) {
    $mainCarousel.flickity( 'select', cellIndex );
  }
});
@desandro
Copy link
Member

Flickity does not have a hover event, but you could build this functionality with jQuery's mouseover event.

See demo https://codepen.io/desandro/pen/LJYxmZ

var $carouselMain = $('.carousel-main').flickity();

var $carouselNav = $('.carousel-nav').flickity({
  asNavFor: '.carousel-main',
  contain: true,
  pageDots: false,
});

// select main on nav hover
$carouselNav.on( 'mouseover', '.carousel-cell', function( event ) {
  var index = $( event.currentTarget ).index();
  $carouselMain.flickity( 'select', index );
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants