Skip to content

Instantly share code, notes, and snippets.

@albell albell/markup.html
Last active Dec 15, 2015

Embed
What would you like to do?
<div class="cycle-slideshow"
data-slides=">div"
data-cycle-auto-height="calc"
>
<div>
<img src="img1.jpg" width="###" height="###">
<p>caption 1</p>
</div>
<div>
<img src="img2.jpg" width="###" height="###">
<p>caption 2</p>
</div>
<div>
<img src="tiniest.gif" data-src="img3.jpg" width="###" height="###">
<p>caption 3</p>
</div>
<div>
<img src="tiniest.gif" data-src="img4.jpg" width="###" height="###">
<p>caption 4</p>
</div>
</div>
$('.cycle-slideshow').on( 'cycle-before', function(e, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag ) {
// the slide after the next slide
futureSlideContents = $(optionHash.slides[optionHash.nextSlide + 1]);
// if the slide has descendants, replace with its descendant imgs
if (futureSlideContents.children().length) {
futureSlideContents = futureSlideContents.find('img');
}
futureSlideContents.each(function() {
// if the source contains "tiniest.gif", replace src with the data-src
if ($(this).attr("src").indexOf("tiniest.gif") >= 0) {
$(this).attr("src", $(this).attr("data-src")); //
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.