cycle2 icon indicating copy to clipboard operation
cycle2 copied to clipboard

Overlay position - vary per slide?

Open manderson725 opened this issue 12 years ago • 4 comments

It is possible for the overlay position to vary by slide? I'm pulling slides from a database table, and the overlay position can be in a variety of spots, but since there is only one overlay call for the slideshow, I'm wondering how i can set the placement per slide. Will I just need to figure out how to manipulate it with additional jquery or is there a way within cycle2. The db table contains a placement field, topleft, topright, bottomright and I'd like to set the overlay position based on those values, but right now I don't see a way within cycle2. Thank you for any help.

manderson725 avatar Apr 22 '14 16:04 manderson725

After digging some more, it seems like I should use nested slideshows to do this, I'm going that route, but I'd still love any suggestions if there are other ways.

manderson725 avatar Apr 22 '14 17:04 manderson725

Haven't really tested it out but maybe there would be someway to do this using data-cycle-overlay-template since it can be overridden on individual slides. The default is "< div >{{title}}< /div > < div >{{desc}}< /div >" so if you could do something like: "< div class="topleft" >{{title}}< /div > < div >{{desc}}< /div >" and change the class for each one and then use css with those class names.

theleewise avatar May 02 '14 17:05 theleewise

I ended up using bullets/li for each slide with a background of the slide image, with a div inside for the overlay piece that i could style based on the db value for the placement. Thank you for the response.

manderson725 avatar May 02 '14 17:05 manderson725

I just solved this issue using some JavaScript for anyone that stumbles upon this page.

jQuery('.cycle-slideshow-one').on('cycle-pager-activated', function(event, optionHash) {
    var thisOverlay = jQuery('.cycle-overlay');
    var pagerIndex = optionHash.currSlide + 1;
    var idName = 'overlay-' + pagerIndex
    thisOverlay.attr('id', idName);
});

Simply style your overlay-# definitions with your desired positions and add position: absolute to your caption-overlay class. Also make sure you add your initial id to the DOM for the initial page rendering.

ghost avatar Dec 23 '15 21:12 ghost