malsup / cycle2

2nd gen cycling
899 stars 236 forks source link

currentSlideEl with cycle-pre-initialize or cycle-initialize #688

Open richgcook opened 9 years ago

richgcook commented 9 years ago

Can you not use currentSlideEl with cycle-pre-initialize or cycle-initialize event? I want to check the current slide on site load/cycle initialisation.

I'm wanting to run a few functions on the first slide/current slide when it initialises. You cannot seem to use the callback signature currentSlideEl with the cycle-pre-initialize or cycle-initialize event? It seems the only event that allows you to use currentSlideEl is cycle-update-view which is, according to the docs, ...triggered after initialization, after a slide transition, and after a slide has been added or removed. However this causes some conflicts with my code as I do not need it to run after a slide transition, and after a slide has been added or removed

Is it possible to use currentSlideEl with the cycle-pre-initialize or cycle-initialize event? This is what I have so far (a snippet!).

$this.on('cycle-update-view', function(event, optionHash, slideOptionsHash, currentSlideEl) {
    var slideBgColor = $(currentSlideEl).data('bgcolor');
    var slideTextColor = $(currentSlideEl).data('textcolor');
    $('body').css('background-color','#' + slideBgColor);
    $('.site-title, .right-navigation ul li a, .holding-slider .each-slide .caption').css('color','#' + slideTextColor);
    $(currentSlideEl).find('.lazy').loadImage();
});