Convert Figma logo to code with AI

fancyapps logofancybox

jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable.

7,281
1,781
7,281
140

Top Related Projects

Pure Javascript lightbox with mobile support. It can handle images, videos with autoplay, inline content and iframes

JavaScript image gallery for mobile and desktop, modular, framework independent

A touchable jQuery lightbox

:zap: Simple and easy to use lightbox script written in pure JavaScript

Full featured JavaScript image & video gallery. No dependencies

Quick Overview

Fancybox is a JavaScript lightbox library for presenting various types of media. It offers a responsive, touch-enabled, and customizable solution for displaying images, videos, and other content in an elegant overlay. Fancybox is designed to enhance the user experience of viewing media on websites.

Pros

  • Responsive and mobile-friendly design
  • Supports a wide range of media types (images, videos, iframes, inline content)
  • Highly customizable with numerous options and API methods
  • Smooth animations and transitions

Cons

  • Requires jQuery as a dependency (as of version 3)
  • May be overkill for simple image gallery needs
  • Learning curve for advanced customizations
  • Performance impact on pages with many lightbox elements

Code Examples

  1. Basic image gallery:
<a href="image1.jpg" data-fancybox="gallery">
  <img src="thumbnail1.jpg">
</a>
<a href="image2.jpg" data-fancybox="gallery">
  <img src="thumbnail2.jpg">
</a>
  1. Video lightbox:
<a href="https://www.youtube.com/watch?v=VIDEO_ID" data-fancybox>
  Watch Video
</a>
  1. Custom options:
Fancybox.bind("[data-fancybox]", {
  animationEffect: "zoom-in-out",
  transitionEffect: "rotate",
  loop: true,
  buttons: ["zoom", "slideShow", "fullScreen", "close"]
});
  1. Programmatically open Fancybox:
Fancybox.show([
  {
    src: "https://lipsum.app/id/1/800x600",
    type: "image"
  },
  {
    src: "<h2>Hello!</h2><p>This is HTML content</p>",
    type: "html"
  }
]);

Getting Started

  1. Include Fancybox CSS and JS files in your HTML:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@4.0/dist/fancybox.css" />
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@4.0/dist/fancybox.umd.js"></script>
  1. Add the data-fancybox attribute to your links:
<a href="large-image.jpg" data-fancybox="gallery">
  <img src="thumbnail.jpg">
</a>
  1. Initialize Fancybox (optional, for custom options):
Fancybox.bind("[data-fancybox]", {
  // Your custom options here
});

Fancybox will automatically work with elements that have the data-fancybox attribute. For more advanced usage and customization, refer to the official documentation.

Competitor Comparisons

Pure Javascript lightbox with mobile support. It can handle images, videos with autoplay, inline content and iframes

Pros of GLightbox

  • Free and open-source, unlike Fancybox which requires a license for commercial use
  • Lighter weight and faster loading times
  • Built-in support for video content from various sources (YouTube, Vimeo, etc.)

Cons of GLightbox

  • Less extensive documentation compared to Fancybox
  • Fewer customization options and advanced features
  • Smaller community and less frequent updates

Code Comparison

GLightbox:

const lightbox = GLightbox({
  selector: '.glightbox',
  touchNavigation: true,
  loop: true
});

Fancybox:

Fancybox.bind("[data-fancybox]", {
  loop: true,
  wheel: "slide",
  Toolbar: false
});

Both libraries offer simple initialization, but Fancybox provides more built-in options for customization. GLightbox focuses on a streamlined approach, while Fancybox offers more advanced features out of the box.

JavaScript image gallery for mobile and desktop, modular, framework independent

Pros of PhotoSwipe

  • More lightweight and performant, especially for large galleries
  • Better touch gesture support and mobile-friendly interface
  • Highly customizable with extensive API and event system

Cons of PhotoSwipe

  • Steeper learning curve and more complex setup
  • Less out-of-the-box styling options
  • Requires more manual configuration for responsive images

Code Comparison

PhotoSwipe initialization:

var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
gallery.init();

Fancybox initialization:

$("[data-fancybox]").fancybox({
  // options
});

PhotoSwipe offers more granular control but requires more setup, while Fancybox provides a simpler API for basic use cases. PhotoSwipe's initialization involves creating a new instance and manually calling the init method, whereas Fancybox uses a jQuery plugin-style approach with a more declarative syntax.

Both libraries are popular choices for image galleries and lightboxes, with PhotoSwipe excelling in performance and customization, while Fancybox offers easier implementation and a wider range of content support out of the box.

A touchable jQuery lightbox

Pros of Swipebox

  • Lightweight and simple to implement
  • Mobile-friendly with touch swipe support
  • Free and open-source

Cons of Swipebox

  • Less feature-rich compared to Fancybox
  • Limited customization options
  • Less frequent updates and maintenance

Code Comparison

Swipebox initialization:

$('.swipebox').swipebox();

Fancybox initialization:

Fancybox.bind("[data-fancybox]", {
  // Options
});

Swipebox offers a simpler initialization process, while Fancybox provides more options for customization. Fancybox's syntax is more modern and flexible, allowing for easier integration with various JavaScript frameworks.

Both libraries serve similar purposes, but Fancybox generally offers more advanced features and better documentation. Swipebox is a good choice for simpler projects or when a lightweight solution is preferred. Fancybox is better suited for more complex implementations and projects requiring extensive customization.

:zap: Simple and easy to use lightbox script written in pure JavaScript

Pros of baguetteBox.js

  • Lightweight and dependency-free, resulting in faster load times
  • Simple and easy to use, with minimal configuration required
  • Open-source and free to use for both personal and commercial projects

Cons of baguetteBox.js

  • Limited features compared to Fancybox's extensive options
  • Less frequent updates and smaller community support
  • Fewer customization options for advanced use cases

Code Comparison

baguetteBox.js:

baguetteBox.run('.gallery');

Fancybox:

Fancybox.bind("[data-fancybox]", {
  // Options
});

Both libraries offer simple initialization, but Fancybox provides more options for customization within the initialization function.

Summary

baguetteBox.js is a lightweight, easy-to-use lightbox solution that's ideal for simple image galleries. It's perfect for projects that prioritize speed and simplicity. However, it lacks some of the advanced features and customization options that Fancybox offers.

Fancybox, on the other hand, provides a more feature-rich experience with extensive customization options. It's better suited for complex projects that require advanced functionality, but it comes at the cost of a larger file size and potential performance impact.

The choice between the two depends on the specific needs of your project, balancing simplicity and lightweight performance against advanced features and customization options.

Full featured JavaScript image & video gallery. No dependencies

Pros of lightgallery.js

  • More lightweight and faster loading times
  • Supports a wider range of media types, including videos and iframes
  • Offers more customization options and plugins

Cons of lightgallery.js

  • Less intuitive API and documentation compared to Fancybox
  • Fewer built-in animation effects and transitions
  • May require more setup and configuration for advanced features

Code Comparison

lightgallery.js:

lightGallery(document.getElementById('lightgallery'), {
    plugins: [lgZoom, lgThumbnail],
    speed: 500,
    download: false
});

Fancybox:

Fancybox.bind("[data-fancybox]", {
    loop: true,
    buttons: ["zoom", "slideShow", "fullScreen", "close"],
    animationEffect: "fade"
});

Both libraries offer easy-to-use initialization methods, but lightgallery.js requires explicit plugin imports for additional features. Fancybox provides more built-in options in its initialization, making it simpler for basic setups.

lightgallery.js excels in performance and flexibility, especially for complex media galleries. However, it may require more effort to achieve the same polished look and feel that Fancybox offers out of the box. Fancybox provides a more user-friendly experience for developers, with better documentation and a more intuitive API, but may be overkill for simpler projects or those prioritizing performance.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Archived

This repository has been archived and is now part of https://github.com/fancyapps/ui

Fancybox

jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable.

Quick start

1. Add latest jQuery and Fancybox files

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>

<link href="/path/to/jquery.fancybox.min.css" rel="stylesheet" />
<script src="/path/to/jquery.fancybox.min.js"></script>

2. Create links

<a data-fancybox="gallery" href="big_1.jpg">
  <img src="small_1.jpg" />
</a>

<a data-fancybox="gallery" href="big_2.jpg">
  <img src="small_2.jpg" />
</a>

3. Enjoy!

License

Fancybox is licensed under the GPLv3 license for all open source applications. A commercial license is required for all commercial applications (including sites, themes and apps you plan to sell).

Read more about Fancybox license.

NPM DownloadsLast 30 Days