Start a new topic

Trigger on front item change?

Hi!
looking about this plugin for a drupal website, i'm asking myself about how to have a event-trigger each time the front item change.

Tryed to use :

  

// Create an event handler.
$('.kc-item').bind('mousemove click',function(evt){
  // Get a reference to the image in the carousel item.
  // Note, we look for one with alt attribute, as the shadow is also an image.
  var $img = $(this).find('[alt]');
  // Pull the text out of the alt attribute and insert into text description div.
  $('#text-description').text($img.attr('alt'));
}); 

  But this one doesn't work when mousewheel is used. (no refresh except with mousemove or click)


Is there an event handler for that precise case?
Thx


1 person likes this idea

Didn't have "killer carrousel" topics in choice menu...

There is no specific event for that, but there is the getFrontItemIndex() API call.


See it working here: http://starplugins.local/killercarousel/examples/api


The example on that page displays the item index number when the carousel changes, similar to what you want to do.

You can use the getItemElement(itemIndex) to get the actual item element so you can pull out text from the alt attribute.


Also, there is a CSS class applied to the front item (.kc-front-item) which may also be useful.

Probably clearer if I show you some code...

(do this after creating the carousel).


// Get carousel instance

kc = $('.kc-wrap').data('KillerCarousel');


// Check every 1/10 second.

setInterval( function(){

    

    // Get front item index.

    var idx = kc.getFrontItemIndex();


    // Get item element.

    $element = kc.getItemElement(idx);

    

    // Do something with $element here...


}, 100)

Thanks, will look this way...

By the way, did you received my license request ? (sended beginning of last week, if my memory is good)

Login or Signup to post a comment