Convert Figma logo to code with AI

brutaldesign logoswipebox

A touchable jQuery lightbox

1,956
667
1,956
189

Top Related Projects

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

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

Full featured JavaScript image & video gallery. No dependencies

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

THE original Lightbox script (v2).

JavaScript image viewer.

Quick Overview

Swipebox is a lightweight, responsive jQuery lightbox plugin. It allows users to create touch-enabled, swipeable image galleries with a clean and modern interface. Swipebox is designed to work seamlessly across desktop and mobile devices.

Pros

  • Easy to implement and customize
  • Responsive design that works well on both desktop and mobile devices
  • Supports touch gestures for swiping through images on mobile
  • Lightweight and fast-loading

Cons

  • Depends on jQuery, which may not be ideal for modern web development practices
  • Limited built-in customization options compared to some more feature-rich lightbox plugins
  • Hasn't been updated in several years, potentially lacking support for newer browser features

Code Examples

  1. Basic implementation:
<a href="large-image.jpg" class="swipebox" title="My Caption">
    <img src="small-image.jpg" alt="image">
</a>

<script type="text/javascript">
    $(document).ready(function() {
        $('.swipebox').swipebox();
    });
</script>
  1. Customizing options:
$('.swipebox').swipebox({
    useCSS: true,
    useSVG: true,
    initialIndexOnArray: 0,
    hideCloseButtonOnMobile: false,
    removeBarsOnMobile: true,
    hideBarsDelay: 3000,
    videoMaxWidth: 1140,
    beforeOpen: function() {},
    afterOpen: null,
    afterClose: function() {}
});
  1. Dynamically adding images:
$.swipebox.extend([
    { href:'big-image1.jpg', title:'My Caption 1' },
    { href:'big-image2.jpg', title:'My Caption 2' }
]);

Getting Started

  1. Include jQuery and Swipebox files in your HTML:
<link rel="stylesheet" href="src/css/swipebox.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="src/js/jquery.swipebox.min.js"></script>
  1. Add Swipebox class to your image links:
<a href="large-image.jpg" class="swipebox" title="My Caption">
    <img src="small-image.jpg" alt="image">
</a>
  1. Initialize Swipebox in your JavaScript:
$(document).ready(function() {
    $('.swipebox').swipebox();
});

Competitor Comparisons

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

Pros of PhotoSwipe

  • More feature-rich with advanced options like pinch-to-zoom and fullscreen mode
  • Better performance and smoother animations, especially for large image galleries
  • Actively maintained with regular updates and bug fixes

Cons of PhotoSwipe

  • Steeper learning curve due to more complex setup and configuration
  • Larger file size, which may impact page load times for smaller projects
  • Requires more JavaScript knowledge to customize and extend functionality

Code Comparison

PhotoSwipe initialization:

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

Swipebox initialization:

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

Summary

PhotoSwipe offers a more robust and feature-rich solution for image galleries, with better performance and ongoing development. However, it comes at the cost of increased complexity and a larger file size. Swipebox, on the other hand, provides a simpler implementation with fewer features but is easier to set up and use, especially for smaller projects or developers with less JavaScript experience.

The choice between the two depends on the specific needs of the project, the desired level of customization, and the developer's expertise. PhotoSwipe is better suited for larger, more complex projects that require advanced functionality, while Swipebox may be preferable for simpler implementations or projects with limited resources.

: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
  • Supports touch gestures for mobile devices out of the box
  • Offers a simple and clean API for easy implementation

Cons of baguetteBox.js

  • Limited customization options compared to Swipebox
  • Fewer animation effects and transitions available
  • May lack some advanced features present in Swipebox

Code Comparison

Swipebox initialization:

$(document).ready(function() {
  $('.swipebox').swipebox();
});

baguetteBox.js initialization:

window.addEventListener('load', function() {
  baguetteBox.run('.gallery');
});

Both libraries offer straightforward initialization, but baguetteBox.js uses vanilla JavaScript, avoiding jQuery dependency. Swipebox requires jQuery, which may be an advantage or disadvantage depending on your project's requirements.

baguetteBox.js provides a more modern approach with its dependency-free nature, making it suitable for projects aiming to reduce external library usage. However, Swipebox offers more customization options and may be preferred for projects requiring extensive styling and animation control.

Consider your project's specific needs, such as performance requirements, desired features, and existing dependencies, when choosing between these two lightbox libraries.

Full featured JavaScript image & video gallery. No dependencies

Pros of lightgallery.js

  • More feature-rich with support for various media types (images, videos, iframes)
  • Better documentation and active development
  • Responsive design and touch-friendly interface

Cons of lightgallery.js

  • Larger file size due to more features
  • Steeper learning curve for advanced customizations
  • May be overkill for simple image gallery needs

Code Comparison

Swipebox initialization:

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

lightgallery.js initialization:

lightGallery(document.getElementById('lightgallery'), {
    selector: '.gallery-item'
});

Both libraries offer simple initialization, but lightgallery.js provides more options for customization out of the box.

Summary

lightgallery.js is a more comprehensive solution with support for various media types and advanced features. It's ideal for projects requiring a versatile gallery solution. Swipebox, on the other hand, is simpler and lighter, making it suitable for basic image gallery needs. The choice between the two depends on the specific requirements of your project, balancing features against simplicity and performance.

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

Pros of Fancybox

  • More feature-rich with advanced options like touch support, zooming, and fullscreen mode
  • Regular updates and active maintenance
  • Extensive documentation and examples

Cons of Fancybox

  • Larger file size due to more features
  • Steeper learning curve for advanced customizations
  • Commercial license required for some use cases

Code Comparison

Swipebox initialization:

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

Fancybox initialization:

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

Both libraries offer simple initialization, but Fancybox provides more customization options out of the box. Swipebox focuses on simplicity, while Fancybox offers a wider range of features and configurations.

Swipebox is lightweight and easy to implement, making it suitable for basic image gallery needs. Fancybox, on the other hand, provides a more comprehensive solution with additional functionality, making it ideal for complex projects requiring advanced media presentation capabilities.

The choice between the two depends on the specific requirements of your project, considering factors such as desired features, performance needs, and licensing considerations.

THE original Lightbox script (v2).

Pros of Lightbox2

  • More actively maintained with recent updates
  • Larger community and user base, resulting in better support
  • Offers more customization options and features

Cons of Lightbox2

  • Slightly larger file size, which may impact page load times
  • More complex setup process compared to Swipebox
  • Requires jQuery, which may not be ideal for all projects

Code Comparison

Swipebox initialization:

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

Lightbox2 initialization:

lightbox.option({
  'resizeDuration': 200,
  'wrapAround': true
});

Both libraries offer simple initialization, but Lightbox2 provides more options for customization directly in the setup code. Swipebox focuses on a more straightforward, plug-and-play approach, while Lightbox2 allows for fine-tuning of various parameters.

Lightbox2 offers a wider range of features and customization options, making it suitable for more complex projects. However, this comes at the cost of a slightly larger file size and more complex setup. Swipebox, on the other hand, provides a simpler, more lightweight solution that may be preferable for smaller projects or those prioritizing quick implementation and minimal overhead.

JavaScript image viewer.

Pros of Viewerjs

  • More feature-rich with support for zooming, rotating, and flipping images
  • Responsive design with touch support for mobile devices
  • Actively maintained with regular updates and bug fixes

Cons of Viewerjs

  • Larger file size and potentially heavier on resources
  • Steeper learning curve due to more complex API and configuration options
  • May be overkill for simple image viewing needs

Code Comparison

Swipebox initialization:

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

Viewerjs initialization:

const viewer = new Viewer(document.getElementById('images'), {
  inline: true,
  viewed() {
    viewer.zoomTo(1);
  },
});

Summary

Viewerjs offers a more comprehensive image viewing solution with advanced features and better mobile support. However, it comes at the cost of increased complexity and resource usage. Swipebox, on the other hand, provides a simpler, lightweight option for basic image viewing needs. The choice between the two depends on the specific requirements of your project and the level of functionality you need for image viewing.

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

Swipebox

A touchable jQuery lightbox.

View project page

What is Swipebox ?

Swipebox is a jQuery "lightbox" plugin for desktop, mobile and tablet.

Features

  • Swipe gestures for mobile
  • Keyboard Navigation for desktop
  • CSS transitions with jQuery fallback
  • Retina support for UI icons
  • Easy CSS customization
  • Video, Images and Inline content

Compatibility

Chrome, Safari, Firefox, Opera, IE9+, IOS4+, Android, windows phone.

Usage

Javascript

Include jquery and the swipebox script in your head tags or right before your body closing tag.

<script src="lib/jquery-3.5.2.js"></script>
<script src="src/js/jquery.swipebox.js"></script>

CSS

Include the swipebox CSS style in your head tags.

<link rel="stylesheet" href="src/css/swipebox.css">

HTML

Use a specific class for your links and use the title attribute as caption.

<a href="big/image.jpg" class="swipebox" title="My Caption">

Fire the plugin

Bind the swipebox behaviour on every link with the "swipebox" class.

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

Options

useCSS : true, // false will force the use of jQuery for animations
initialIndexOnArray: 0, // which image index to init when a array is passed
removeBarsOnMobile : true, // false will show top navigation bar on mobile devices
hideCloseButtonOnMobile : false, // true will hide the close button on mobile devices
removeBarsOnMobile : true, // false will show bottom bar on mobile devices
hideBarsDelay : 3000, // delay before hiding bars on desktop
videoMaxWidth : 1140, // videos max width
beforeOpen: function(){} , // called before opening
afterOpen: null, // called after opening
afterClose: function(){}, // called after closing
afterMedia: function(){}, // called after media is loaded
loopAtEnd: false, // true will return to the first image after the last image is reached
autoplayVideos: false // true will autoplay Youtube and Vimeo videos
queryStringData: {} // plain object with custom query string arguments to pass/override for video URLs,
toggleClassOnLoad: '' // CSS class that can be toggled when the slide will be loaded (like 'hidden' of Bootstrap)
useSVG: true
nextSlide: function(){} // called on next slide, works for next button, arrow keys and touch navigation
prevSlide: function(){} // called on previous slide, works for previous button, arrow keys and touch navigation

Pull Requests

I want to keep this plugin as simple as possible. I won't merge pull requests for additional features such as download buttons, social like buttons, IE8 compatibility etc... But feel free to fork the project and customize it to suit to your needs. Most wanted PR are for bug fixes. Also, a future improvement will be to allow zoom on touchable devices.

If you want to submit a pull request please be sure to grunt the whole thing (mostly jshintrc validation and minified file) and send me a demo URL. Also, please comment your code.

Thanks for your understanding and thank you all for your helpful support!