A touchable jQuery lightbox

Overview

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!

Comments
  • Get selector from options (for jQuery 3)

    Get selector from options (for jQuery 3)

    This change provides compatibility with jQuery 3 by changing the way Swipebox works with dynamic content. Swipebox is no longer dynamic by default as the "selector" jQuery property that it previously relied on has been removed in jQuery 3.

    To make Swipebox work with dynamic content it must instead be initialised by passing the selector as an option, similar to Bootstrap's popovers/tooltips. Only do this for dynamic content.

    $(document).swipebox({ selector: '.swipebox' });
    

    For non-dynamic uses, simply apply this PR and you're done. You do not need the selector option. Dynamic content refers to galleries where images may be added or removed on the fly.

    Fixes #295.

    opened by andrews05 16
  • On mobile, iOS7 interferes with the closing of the lightbox

    On mobile, iOS7 interferes with the closing of the lightbox

    When on mobile, if you open a lightbox and you try to close it by going for the X at the bottom left the bottom bar of the safari browser will appear and thus cover the X to close the lightbox.

    opened by espitia 13
  • Mobile Safari iOS 7 close swipebox bug

    Mobile Safari iOS 7 close swipebox bug

    When viewing a swipebox gallery on Mobile Safari iOS7 and the user clicks the close button the browser's native navigation overlays the swipebox bar and swipebox cannot be closed without refreshing the page

    swipebox_bug

    opened by andyexeter 11
  • Windows Phone 8.0 (Mobile IE 10.0) - viewport not fixed, buttons not working, no touch

    Windows Phone 8.0 (Mobile IE 10.0) - viewport not fixed, buttons not working, no touch

    I've integrated Swipebox into my blog for some time now. Recently, I've switched to a Windows Phone (Lumia 1020). Running the latest firmware, I've noticed that while the Swipebox opens normally on click, the viewport remains scrollable. This happens both on the demo site and on my blog. Furthermore, the buttons are clickable, but don't actually do anything. To close the Swipebox, I've got to reload the page.

    The weird thing is, earlier today I tried the demo site and it seemed to work fine - except that you could still scroll the page in the background (1 px was visible underneath the black). I thought that maybe the problem had been fixed by the recent changes, but after I upgraded my Swipebox codebase to master, nothing changed. I tried the demo site again and this time it handled exactly the same as my blog, i.e. I can scroll away from the Swipebox (black background) and the buttons don't really work. Oh, and touch gestures don't work, either.

    opened by mundschenk-at 10
  • Thumbnail grouping

    Thumbnail grouping

    First of all beautiful plugin!

    I was wondering if it's possible to add thumbnail grouping (either by "rel" or "data-swipeboxgroup"). This is so that if there are several groups of thumbnails on a page then opening one will only create a swipebox for the images in its group, rather than all the images on the page.

    opened by oozrafa 9
  • Webpack black screen

    Webpack black screen

    I'm using webpack to bundle all my css / js files. I have installed swipebox with npm install swipebox and initialised it like so:

    import 'swipebox/src/css/swipebox.css';
    import swipebox from 'swipebox';
    $( '.swipebox' ).swipebox();
    

    Now whenever i click anywhere on the screen the swipebox modal appears but nothing is in it. So basically i get a black screen with a closing button (which doesn't work).

    I don't have any errors in my console or terminal (from compiling with webpack). What am i doing wrong?

    opened by justijndepover 8
  • iPhone bottom menu covering close button

    iPhone bottom menu covering close button

    I love swipebox, it does exactly what I want it to do, except in testing on iPhone the close button is being covered by the iPhone bottom menu. Since you can't scroll vertically in swipe box it is difficult to remove the menu. I tried to play with the css, but I can't get it to not cover it up. If I switch from portrait to landscape a couple of times the close button appears above the menu, but initially it does not. Does anyone have any idea on how to trouble shoot this?

    opened by wgoodman 8
  • mp4 video support

    mp4 video support

    Hi,

    Is it very difficult to include support for viewing mp4 and other video formats in swipebox? I know I can use youtube/vimeo urls but my client wants to host videos in his own server for legal reasons. Could you please add this capability?

    opened by RobertoCMCosta 8
  • Perfect this swipebox!!!

    Perfect this swipebox!!!

    Very good plugin, works perfectly!

    I wonder if he supports putting the count of photos in the gallery, for example: Photo 1 of 367

    Is that possible?

    Thank you!

    enhancement 
    opened by bdadev 8
  • how do i force swipebox to reinitialize?

    how do i force swipebox to reinitialize?

    i try to combine swipebox with isotope on one page. now when i filter my photos on the page with isotope i'm able to remove the swipebox class from my links. and add them if i choose to show another selection. but swipebox keeps it's original set of pictures, meaning i allways see all the pictures in swipebox and not just the ones that are filterd now.

    does anybody have a clue how to fix this?

    enhancement 
    opened by nino-zeke 7
  • allow an addtional image caption

    allow an addtional image caption

    The attribute for title and caption are now configurable via the option array. A caption is usful to give an additional image description or provide proper attribution. This includes the XSS fix from #268

    opened by splitbrain 6
  • Problem with Multiple Galleries on Same Page

    Problem with Multiple Galleries on Same Page

    The fix made for jQuery 3.x was this to forcefully add a swipebox class to the calling element, and then to have the selector variable use that class. While this works fine in some cases, in other cases it causes quite a lot of problems.

    In my use case, there are multiple types of galleries on the same page, each with different settings. When you are setting the selector to be universally .swipebox, the binding is getting messy, and the settings of one gallery tend to overlap with another. E.g. I have different functions for the beforeOpen and afterOpen events based on the selectors, but the one defined last is overriding all the others. This is problematic, since it tends to result in errors if certain conditions that would be met for one selector don't apply to the others.

    I believe you might want to consider an alternative to hardcoding the selector to .swipebox. The implementation here lets you define a setting called selector, and then use that setting: https://github.com/mho79/swipebox/blob/master/src/js/jquery.swipebox.js.

    I would propose a hybrid - you can add the option for the selector, then, in your plugin.init function, use the option if not null. If null, then use the default .swipebox that you added to all elements. This way, users will not have to change their code, and you will be able to fix the bug too.

    opened by sayontan 0
  • Allow an additional image caption (PR #269 followup)

    Allow an additional image caption (PR #269 followup)

    This is a follow up of the previously raised PR. That one was agreed to be merged, but had merge conflicts and seems like the author of the PR has stopped maintaining it.

    The original description was: "The attribute for title and caption are now configurable via the option array. A caption is usful to give an additional image description or provide proper attribution. This includes the XSS fix from https://github.com/brutaldesign/swipebox/pull/268"

    I like the idea of having an ability to add an optional comment to the photo, as for example in my gallery I'm storing comments in JPEG's tags. They can be multi-line and are not necessarily suitable for the main title. In the original version, the title doesn't support multiple lines allowing the text to overflow.

    JS is not my specialty, I just replicated the original changes, so happy to incorporate corrections/suggestions if any

    opened by maxim-kukushkin 3
  • Popup Close button click event not working

    Popup Close button click event not working

    Hello developers,

    I try to add click event on the close button over the swipebox-overy but I can't fix anybody help how to add my custom event on there

    My code is: jQuery(document).on('click', '#swipebox-close' , function() { jQuery(body).css('color', 'red'); });

    opened by dipak24 2
  • JQMIGRATE: jQuery.isArray is deprecated; use Array.isArray

    JQMIGRATE: jQuery.isArray is deprecated; use Array.isArray

    I just updated from 1.3.0.2 to 1.5.1 to eliminate the black screen on click issue with the newest Wordpress update. I am currently troubleshooting a variety of jQuery depreciations, using the jQuery Migrate plugin for tracking.

    Currently, it appears that the site is now functioning correctly, but I am concerned about future issues based on the logging of the depreciated array syntax logged above.

    opened by louthenw 3
Owner
null
A light-weight, customizable lightbox plugin for jQuery

About Colorbox: A customizable lightbox plugin for jQuery. See the project page for documentation and a demonstration, and the FAQ for solutions and e

Jack Moore 4.8k Dec 29, 2022
jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable.

fancyBox jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable. See the project page for doc

Jānis Skarnelis 7.2k Jan 2, 2023
Light and responsive lightbox script with focus on performance.

Magnific Popup Repository Fast, light and responsive lightbox plugin, for jQuery and Zepto.js. Documentation and getting started guide. Examples and p

Dmitry Semenov 11.3k Jan 2, 2023
:zap: Simple and easy to use lightbox script written in pure JavaScript

baguetteBox.js Simple and easy to use lightbox script written in pure JavaScript. Demo page Table of contents Features Installation Importing Usage Cu

Marek Grzybek 2.3k Jan 3, 2023
A customizable, modular, responsive, lightbox gallery plugin.

lightGallery A customizable, modular, responsive, lightbox gallery plugin for jQuery. Demo JQuery lightGallery demo. Codepen demo Main features Fully

Sachin N 5.6k Jan 4, 2023
THE original Lightbox script (v2).

Lightbox2 The original lightbox script. Lightbox is small javascript library used to overlay images on top of the current page. It's a snap to setup a

Lokesh Dhakar 5.8k Jan 3, 2023
Touch-friendly image lightbox for mobile and desktop

Touch-friendly image lightbox for mobile and desktop

Andre Rinas 938 Jan 5, 2023
jQuery PopBox UI Element

jQuery PopBox jQuery PopBox is a simple balloon UI element inspired by 37Signals Highrise CRM. See it in action here: http://gristmill.github.com/jque

Gristmill 427 Sep 24, 2022
Avgrund is jQuery plugin with new modal concept for popups

Avgrund Avgrund is a jQuery plugin for your modal boxes and popups. It uses new concept showing depth between popup and page. It works in all modern b

Dmitri Voronianski 1.8k Dec 14, 2022
jBox is a jQuery plugin that makes it easy to create customizable tooltips, modal windows, image galleries and more.

jBox jBox is a jQuery plugin that makes it easy to create customizable tooltips, modal windows, image galleries and more. Demo: https://stephanwagner.

Stephan Wagner 1.4k Dec 15, 2022
Elegant, responsive, flexible and lightweight modal plugin with jQuery.

iziModal Elegant, responsive, flexible and lightweight modal plugin with jQuery. izimodal.marcelodolza.com Fast Responsive Animated Lightweight Custom

Marcelo Dolza 2.1k Dec 30, 2022
The simplest possible modal for jQuery

A simple & lightweight method of displaying modal windows with jQuery. For quick examples and demos, head to jquerymodal.com. Why another modal plugin

Kyle Fox 2.5k Dec 29, 2022
A Lightweight Responsive jQuery Tooltip Plugin

tipso A Lightweight Responsive jQuery Tooltip Plugin There is also a Wordpress version of this plugin. Get it here Getting started Include jQuery <scr

Bojan Petkovski 325 Dec 21, 2022
Bootstrap-Lightbox - Simple & lightweight lightbox for Bootstrap 5

Bootstrap-Lightbox Simple & lightweight lightbox for Bootstrap 5 Basic Usage Adding data-modal="bs-lightbox" in your A href tag. <a data-modal="bs-lig

null 1 Oct 11, 2022
A light-weight, customizable lightbox plugin for jQuery

About Colorbox: A customizable lightbox plugin for jQuery. See the project page for documentation and a demonstration, and the FAQ for solutions and e

Jack Moore 4.8k Dec 29, 2022
jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable.

fancyBox jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable. See the project page for doc

Jānis Skarnelis 7.2k Jan 2, 2023
Responsive no-jQuery pure JS/CSS Lightbox for images, no dependencies, 10kb unminified source code, with demo

img-lightbox Responsive no-jQuery pure JS/CSS Lightbox for images, no dependencies, 10kb unminified source code, with demo Demo codepen jsfiddle jsbin

englishextra 12 Jun 13, 2022
Light and responsive lightbox script with focus on performance.

Magnific Popup Repository Fast, light and responsive lightbox plugin, for jQuery and Zepto.js. Documentation and getting started guide. Examples and p

Dmitry Semenov 11.3k Jan 2, 2023
:zap: Simple and easy to use lightbox script written in pure JavaScript

baguetteBox.js Simple and easy to use lightbox script written in pure JavaScript. Demo page Table of contents Features Installation Importing Usage Cu

Marek Grzybek 2.3k Jan 3, 2023
A customizable, modular, responsive, lightbox gallery plugin.

lightGallery A customizable, modular, responsive, lightbox gallery plugin for jQuery. Demo JQuery lightGallery demo. Codepen demo Main features Fully

Sachin N 5.6k Jan 4, 2023