Created
March 7, 2016 18:21
-
-
Save paulstraw/80b5c2c8473f2d9067f9 to your computer and use it in GitHub Desktop.
Using Drift with multiple images and images loaded via ajax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <img class="thumb" src="http://assets.imgix.net/dog.png?w=100" data-zoom="http://assets.imgix.net/dog.png?w=1200"> | |
| <img class="thumb" src="http://assets.imgix.net/cat.png?w=100" data-zoom="http://assets.imgix.net/cat.png?w=1200"> | |
| <img class="thumb" src="http://assets.imgix.net/frog.png?w=100" data-zoom="http://assets.imgix.net/frog.png?w=1200"> | |
| <img class="thumb" src="http://assets.imgix.net/llama.png?w=100" data-zoom="http://assets.imgix.net/llama.png?w=1200"> | |
| <p>Aenean lacinia bibendum nulla sed consectetur. Vestibulum id ligula porta felis euismod semper. Donec id elit non mi porta gravida at eget metus. Donec ullamcorper nulla non metus auctor fringilla.</p> | |
| <div class="more-thumbs"> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Using vanilla JS to demo multiple image handling | |
| var thumbs = document.querySelectorAll('.thumb'); | |
| var para = document.querySelector('p'); | |
| for (var i = 0, len = thumbs.length; i < len; i++) { | |
| var thumb = thumbs[i]; | |
| new Drift(thumb, { | |
| paneContainer: para | |
| }); | |
| } | |
| // Using jQuery to demo AJAX loading | |
| var moreThumbsContainer = $('.more-thumbs'); | |
| moreThumbsContainer.load('more-thumbs.html', function() { | |
| moreThumbsContainer.find('.more').each(function(i, el) { | |
| new Drift(el, { | |
| paneContainer: para | |
| }); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <img class="more" src="http://assets.imgix.net/trees.png?w=100" data-zoom="http://assets.imgix.net/trees.png?w=1200"> | |
| <img class="more" src="http://assets.imgix.net/mountains.png?w=100" data-zoom="http://assets.imgix.net/mountains.png?w=1200"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment