Skip to content

Instantly share code, notes, and snippets.

@reinink
Last active December 14, 2015 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reinink/5032223 to your computer and use it in GitHub Desktop.
Save reinink/5032223 to your computer and use it in GitHub Desktop.
JavaScript that will load the PhotoSwipe library for mobile (touch) users, and the Fancybox library for desktop users. This requires yepnope.js (which is bundled with Modernizr).
yepnope(
{
test: Modernizr.touch,
yep: ['/photoswipe/klass.js', '/photoswipe/photoswipe.js', '/photoswipe/photoswipe.css'],
nope: ['/fancybox/jquery.fancybox.js', '/fancybox/jquery.fancybox.css'],
complete: function()
{
var selector = $('.image_link');
if (Modernizr.touch)
{
selector.photoSwipe();
}
else
{
selector.fancybox();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment