You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For non-random lookahead rotators I've found that at least the first 2 slide images have to be marked up normally (without the data-cycle-src attribute), however this doesn't work with the random option since it isn't known which slides will appear first.
Adding this snippet (updating the selector as needed) within the lookahead loading plugin loads the first two of the randomized slide images immediately:
// other plugin stuff above...
$(document).on( 'cycle-initialized', function(e, opts) {
// load first 2 images after randomizing
var firstimages = document.querySelectorAll('.cycle-slideshow li:nth-child(-n+2) img[data-cycle-src]');
for (var i = 0; i < firstimages.length; i++) {
firstimages[i].src = firstimages[i].dataset.cycleSrc;
firstimages[i].removeAttribute('data-src');
}
var key = 'cycle-look-ahead';
// other plugin stuff below...
Note that using an appropriately-sized placeholder src image and height/width attributes avoids potential issues with autoheight, centering and reflow:
In case it's useful to anyone:
For non-random lookahead rotators I've found that at least the first 2 slide images have to be marked up normally (without the
data-cycle-src
attribute), however this doesn't work with the random option since it isn't known which slides will appear first.Adding this snippet (updating the selector as needed) within the lookahead loading plugin loads the first two of the randomized slide images immediately:
Note that using an appropriately-sized placeholder
src
image andheight
/width
attributes avoids potential issues with autoheight, centering and reflow:The text was updated successfully, but these errors were encountered: