Code Monkey home page Code Monkey logo

lightgallery's Introduction

commit npm npm-tag size tree-shaking types hits

lightGallery

A customizable, modular, responsive, lightbox gallery plugin. No dependencies.\ Available for React.js, Angular, Vue.js, and typescript.

lightgallery

Core features

  • Fully responsive.
  • Modular architecture with built in plugins.
  • Highly optimized for touch devices.
  • Mouse drag supports for desktops.
  • Double-click/Double-tap to see actual size of the image.
  • Animated thumbnails.
  • Social sharing.
  • YouTube Vimeo Wistia and html5 videos Support.
  • 20+ Hardware-Accelerated CSS3 transitions.
  • Dynamic mode.
  • Inline gallery.
  • Full screen support.
  • Zoom in/out, Pinch to zoom.
  • Swipe/Drag up/down support to close gallery.
  • Browser history API(deep linking).
  • Responsive images.
  • HTML iframe support.
  • Multiple instances on one page.
  • Easily customizable via CSS (SCSS) and Settings.
  • Smart image preloading and code optimization.
  • Keyboard Navigation for desktop.
  • SVG icons.
  • Accessibility support.
  • Rotate, flip images.
  • And many more.

Documentation

Installation

lightGallery is available on NPM, Yarn, Bower, CDNs, and GitHub. You can use any of the following method to download lightGallery.

  • NPM - NPM is a package manager for the JavaScript programming language. You can install lightgallery using the following command

    npm install lightgallery
  • YARN - Yarn is another popular package manager for the JavaScript programming language. If you prefer you can use Yarn instead of NPM

    yarn add lightgallery
  • Bower - You can find lightGallery on Bower package manager as well

    bower install lightgallery --save
  • GitHub - You can also directly download lightgallery from GitHub

  • CDN - If you prefer to use a CDN, you can load files via jsdelivr, cdnjs or unpkg

Include CSS and Javascript files

First of all, include lightgallery.css in the <head> of the document. If you want include any lightGallery plugin such as thumbnails or zoom, you need to include respective css files as well.

Alternatively you can include lightgallery-bundle.css which contains lightGallery and all plugin styles instead of separate stylesheets.

If you like you can also import scss files instead of css files from the scss folder.

<head>
    <link type="text/css" rel="stylesheet" href="css/lightgallery.css" />

    <!-- lightgallery plugins -->
    <link type="text/css" rel="stylesheet" href="css/lg-zoom.css" />
    <link type="text/css" rel="stylesheet" href="css/lg-thumbnail.css" />


    <!-- OR -->

    <link type="text/css" rel="stylesheet" href="css/lightgallery-bundle.css" />
</head>

Then include lightgallery.umd.js into your document. If you want to include any lightgallery plugin you can include it after lightgallery.umd.js.

<body>
    ....

    <script src="js/lightgallery.umd.js"></script>

    <!-- lightgallery plugins -->
    <script src="js/plugins/lg-thumbnail.umd.js"></script>
    <script src="js/plugins/lg-zoom.umd.js"></script>
</body>

lightGallery supports AMD, CommonJS and ES6 modules too.

import lightGallery from 'lightgallery';

// Plugins
import lgThumbnail from 'lightgallery/plugins/thumbnail'
import lgZoom from 'lightgallery/plugins/zoom'

The markup

lightgallery does not force you to use any kind of markup. you can use whatever markup you want. Here can find detailed examples of different kinds of markups.

If you know the original size of the media, you can pass it via data-lg-size="${width}-${height}" attribute for the initial zoom animation. But, this is completely optional.

<div id="lightgallery">
    <a href="img/img1.jpg" data-lg-size="1600-2400">
        <img alt=".." src="img/thumb1.jpg" />
    </a>
    <a href="img/img2.jpg" data-lg-size="1024-800">
        <img alt=".." src="img/thumb2.jpg" />
    </a>
    ...
</div>

Initialize lightGallery

Finally, you need to initiate the gallery by adding the following code.

<script type="text/javascript">
    lightGallery(document.getElementById('lightgallery'), {
        plugins: [lgZoom, lgThumbnail],
        speed: 500,
        licenseKey: 'your_license_key'
        ... other settings
    });
</script>

CodePen Demos

License Key

You'll receive a license key via email one you purchase a license More info

Plugins

As shown above, you need to pass the plugins via settings if you want to use any lightGallery plugins.

If you are including lightGallery files via script tag, please use the same plugins names as follows.

lgZoom, lgAutoplay, lgComment, lgFullscreen , lgHash, lgPager, lgRotate, lgShare, lgThumbnail, lgVideo, lgMediumZoom

Browser support

lightGallery supports all major browsers including IE 10 and above.

License

Commercial license

If you want to use lightGallery to develop commercial sites, themes, projects, and applications, the Commercial license is the appropriate license. With this option, your source code is kept proprietary. Read more about the commercial license

Open source license

If you are creating an open source application under a license compatible with the GNU GPL license v3, you may use this project under the terms of the GPLv3.

Support

If you have any questions, suggestions, feedback, please reach out to [email protected] or DM me on twitter

lightgallery's People

Contributors

abnersajr avatar ajuzp5 avatar andrevitalb avatar andysbliss avatar bytesandbots3 avatar catsand avatar coliff avatar dchekanov avatar domoritz avatar dsrec77 avatar escaped avatar graceman9 avatar hctom avatar jlukic avatar jochienabuurs avatar kukac7 avatar kurre avatar nasskalt avatar nathanwalker avatar niklasp avatar sachinchoolur avatar searleb avatar smelamud avatar tammo0 avatar timbarden avatar timgates42 avatar ujjwalm1999 avatar watarumohawk avatar xanderrock avatar zmalter99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lightgallery's Issues

HTML-Content

Hello, I have a question for this super lightGallery.

Is it possible to load inline-content and extern content (same domain)?

Thank you very much

Greetings

in your destroy method do:

minimize code, and also it's better practice NOT to create a new jQuery object when you already have it.

$('.lightGallery').unbind('mousedown');
$('.lightGallery').unbind('mouseup');
$('body').removeClass('touch');
$('body').unbind('touchstart');
$('body').unbind('touchmove');
$('body').unbind('touchend');
$(window).unbind('resize');
$(window).unbind('keyup');

to:

$('.lightGallery').off('mousedown mouseup');
$(document.body).removeClass('touch').off('touchstart touchmove touchend');
$(window).off('resize keyup');

Image Gallery will not continue after 3rd image - Uncaught TypeError

I've implemented many sets of images so I know it's not the images I'm using. However, I get this issue every time. See below.

lightgallery

Uncaught TypeError: Cannot read property 'match' of undefined lightGallery.js:229
setUp.isVideo lightGallery.js:229
setUp.loadContent lightGallery.js:277
setUp.loadContent lightGallery.js:309
setUp.slide lightGallery.js:564
setUp.nextSlide lightGallery.js:536
(anonymous function) lightGallery.js:478
b.event.dispatch jquery.js:9593
v.handle jquery.js:9273

Provide a single source of documentation on settings

Currently settings are described in at least 3 locations:

  • Pages - index (short)
  • Pages - "Settings" (extensive)
  • Project - readme (short)

It would be easier for new users and documentation maintainers if there will be only one source (Pages - "Settings", probably). Other places can have links for that source.

Allow definition of click target

Hi,

Right now the plugin captures the immediate children of the gallery node for click events, preventing anything within to define it's own events without propagation.

I had to place e.g. a Pinterest button over the image. Clicking it was capture by the gallery plugin and the pinterest action never executed.

It would help if we could have a custom selector property, which the gallery would isolate as the click-targets and let everything else pass through.

Thanks much for the consideration. Great plugin otherwise!

Juergen

iOS Safari address bar and toolbar problem

When loading a gallery in iOS Safari, if you click at the bottom edge of the screen, the Safari toolbar and address bar pop up and overlap the controls. This makes it impossible to close the gallery or use the next/prev/thumbnail controls at the bottom because the positioning of those elements doesn't react to the Safari toolbars showing up. Any thoughts on how to fix this issue?

Allow Dimmer Click to Close Gallery

Its a common lightbox interaction to allow clicking on the "dimmed" area outside of the image to cause the lightbox to close.

This isn't currently available in lightGallery, and would be a great enhancement.

Titles and Descriptions

hi,

thank you very much for this great plugin.

i guess there is issue in titles and descriptions.
sometimes is situation when you want on first item titles and desc's, but you dont want them on second or third items.
when they are enabled, it shows on items (which dont have "data-title" and "data-desc" attributes) titles as "image 0"

by fixing it i have uncommented lines 377 and 403.

also replaced line 388 with this:
if (typeof title == 'undefined' || title == null) {} else {$slide.eq(i).append('<div class="info group"><span class="title">' + title + '</span></div>');}

and line 408 with this:
if (typeof description == 'undefined' || description == null) {} else {$slide.eq(i).find('.info').append('<span class="desc">' + description + '</span>');}

also line 406 with this:
if (typeof description == 'undefined' || description == null) {} else {$slide.eq(i).append('<div class="info group"><span class="desc">' + description + '</span></div>');}

after that it shows titles of items which have those attributes and dont shows that "image 0" titles for items which dont have those attributes.

but maybe there is better way?
Thank you very much

iOS/Safari problem

Hi!
First i have to say - Great work! LightGallery looks and works good, I just found one bug:

On iOS Safari (tested with iPad2 and iPhone4, with and without private browsing) screen freezes after closing the LightGallery and the only way get touch screen working again is to refesh the page.
I found this same bug on several pages using LightGallery, ie. http://sachinchoolur.github.io/lightGallery/

Thanks!

IE9 issue

Hello,
great plugin, however the default easing mode does not work in IE9 (at least).
Changing it to easing: 'linear' fixes the problem.

Launching the gallery from an external button

I absolutely love this plugin, its simple to use and looks gorgeous!
Can I launch the gallery by clicking a button which is outside the div containing the images on the same page?

Click to launch gallery

  • img
  • img

thanks

iOS links not working

Hi again Sachin,

in iOS the links and navigation arrows do not work. I don't know if this is a touch problem in general rather than iOS specific?

Add lightGallery to bower.io package manager

Bower is a package manager for the web. It offers a generic, unopinionated solution to the problem of front-end package management, while exposing the package dependency model via an API that can be consumed by a more opinionated build stack. There are no system wide dependencies, no dependencies are shared between different apps, and the dependency tree is flat.

See http://bower.io/#defining-a-package

Change the html structure

It could be cool to have the possibility to change the html structure for something like :

$("#mycontent").lightGallery({
selector: '.content_item',
});

Thanks for your great plugins :)

IOS on iphone close button not working for videos

Hi, Thanks again for the fantastic lightGallery.

I have an issue which seems to occur on IOS for iphone only. (It's not an issue on ipad.) Basically I have a light gallery which contains a YouTube video, it appears fine in the gallery and plays, but when you touch the close button (after playing it) it tries to load another gallery on top. Basically all that appears is black with the slide counter and close button, the counter keeps increasing with every touch of the close button.

I have checked via the safari developer console and every time the close button is touched an empty lightGallery is loaded:

<div id="lightGallery-outer"><div id="lightGallery-Gallery"><div id="lightGallery-slider"></div><a id="lightGallery-close" class="close"></a></div></div>

I think the reason this is only happening on the iphone (and I assume on ipod touch too) is that when a video is played it opens up in the ios native player rather than in 'on the page' It's worth pointing out that this problem also occurs on the http://sachinchoolur.github.io/lightGallery/index.html examples.

If anyone is able to provide a solution for this I would appreciate it, trying to implement this for the launch of a new site.

Many thanks

RTL Support

hi,
this is an awesome lightbox i love it and thank you very much for the work on it.

the problem i have however is that in Right To Left pages everything gets inverted wrongly, i guess it is because of the CSS display:inline-block;

is there a way to support RTL?

thanks in advanced.

Mention default and possible values for each setting

It would be nice to know the default and possible values for settings.
Something like the following:

Name Possible values Default value Description
mode 'slide', 'fade' 'slide' What kind of animation to use when transitioning between images

Let me know if you need some help with this (#26 should probably be resolved first).

resize eventListener for responsive websites doesnt listen after lightGallery got closed

I found a problem/bug:

When i add lightGallery to a responsive website which already has an eventListener on window resize, lightGallery removes the listener when it gets closed.

For example: http://jsfiddle.net/EPLWV/1/
Resize the content frame and you can see everything works fine. When you click on an image lightGallery opens and is responsive too. When you close lightGallery to continue surfing on the page, the page lost its responsive function.

Quick solution: to prevent lightGallery removing all resize listenings on the window element, just remove "$(window).off('resize keyup');" from lightGallerys sourcecode inside the destroy function.

Stable solution: give a namespace for lightGallery events: http://stackoverflow.com/questions/13268424/removing-the-window-resize-event-in-jquery

Keep up the good work! ๐Ÿ‘

regards

Portrait Image Thumbnails

If you have a portrait image in the gallery and you open up the thumbnail drawer, the portrait image is left aligned and only takes up around half of the thumbnail box.

iPad Crashing

Hi Sachin,

Have you been able to fix the issue with the light gallery on the iPad where it seems to crash when there are more than 18 images it needs to handle (Original issue post: #36) ? I also know that one page I had too many images in the gallery and it wouldn't work unless i split the images in separate uls. But doing this means they are in separate galleries when they actually should all in the same gallery. Are these issues you'll be able to look into and resolve please? Thanks in advance!

  • Jodie

Large galleries crash iOs devices

Larger galleries seem to crash safari on older iPads, the issue can somewhat be mitigated by using lower res images for those devices but a better option would be to not preload all images but only the next/previous 2. I would really like to see an option where this can be set.

Close and reinitialise lightGallery with external click

Hi,

I want to be able to close the lightGallery by clicking something external/outside of the lightGallery area (ie. not the normal "X" Close button), and then reopen it in the normal way with default settings. How can I do this? It seems I can only do this if I use the "#lightGallery-close" icon to close it?

Thanks.

Font icons

I'm confused why you include

@font-face {
font-family: 'Slide-icons';
src: url('../font/Slide-icons.eot');
}

In the CSS file but do not include the font folder in the download?

Automatically load thumbnail images for youtube links

According to stackoverflow you can get the default thumbnail icon for a Youtube video with:

http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg

This would be a cool feature to support by default (especially for the 'dynamic' option) As it currently is, if you don't manually set the thumbnail it just shows as a broken image.

Position problem #lightGallery-action

The '#lightGallery-action' is slightly off centered. Since '#lightGallery-prev', '.cLthumb', and '#lightGallery-next' have a width of 31px each, the margin-left offset for lightgallery-action should be 93/2 px.

Safari on IPad keeps crashing when gallery opened

Hi,

The gallery is pretty cool and easy to use. I have an issue though when trying to use it in Safari on an iPad. Every time I open the gallery the gallery pops up for a second then the browser closes completely.

What have I missed?

...a bit more information here:

I have multiple galleries showing using relations to match them, so:

    $('#rel1').lightGallery({rel:true});
    $('#rel2').lightGallery({rel:true});
    $('#rel3').lightGallery({rel:true});        
    $('#rel4').lightGallery({rel:true});
     ....ect

then the galleries as follows:

< ul id="rel1" data-rel="imageGallery1">< li .......etc
< ul id="rel2" data-rel="imageGallery1">< li........etc

< ul id="rel3" data-rel="imageGallery2"><li .......etc
< ul id="rel4" data-rel="imageGallery2"><li........etc

and so on...... this works fine on desktops and iPhone so I assume the code is ok.

Thanks,
Chris

ul li elements stacking vertically

I have a lightGallery with videos and for some reason its only stacking in one line vertically. I'm using Bootstrap 3 as well, but I don't believe any default style would override lightGallery. Is there a param for setting horizontal listings?

remove/destroy/reinitialize

Hi there,
i really like and enjoy lightGallery, great work!

My scenario uses a filter system for the images inside my gallery.
Because of that i need to reinitialize and/or complete remove the lightGallery.
I already found the undocumentated $("selector").lightGallery("destroy") method but it doesnt really removes the functionality and ends up, by clicking on a thumb, in showing the black background and returning network errors (trying to load an "undefined").
Is there any way to do it out of the box?

greetings

Invisible buttons on IE8

Hi!
Seems that iconic font is not working on IE8. Buttons are there but nothing is displayed.
Take a look here http://i.imgur.com/g2DVLZw.jpg

Also a quick question if you don't mind: I'm using the dynamic mode. Is possible to slide to a precise image after the lightbox initialization? thanks

Apply to image only

It would helpful if you could apply the data-src and options directly to the image tag instead of having to wrap it in divs or ul/li's. I'm using this as a light box replacement where I have individual images spread all over the page opening up to one gallery and it seems unnecessary for this scenario to have to have the wrappers.

PS. Excellent job on this plugin btw. It's one of the best light box style gallery plugins i've seen in a long time.

Pause youtube videos when changing slide

Not 100% if this is already possible by an option, but I noticed on the demo's that youtube videos keep playing in the background when you click next/prev.

This can be controlled with the Youtube JS API / this stackoverflow post, and could easily be manually added into the onSlideBefore / onSlideNext / onSlidePrev handlers, though it feels like something that would be good to support by default with an option.

Thoughts?

Feature request: Display image on load

Hi, are you considering implementing a 'wait until image is fully loaded before showing' function?

I only ask as my custom function designed to do this does not do it very gracefully and I am not a good enough coder to smooth out said bugs.

Grouping dont work correctly

There is a problem with rel attribute and grouping galleries. It dont working corretly. For example you can see on Demo page

dynamical load

Because I have to use dynamical load to integrate lightGallery to my website, I 'm unable to use Youtube's links. Any reason? Vimeo's links work fine.

Add links inside lightbox?

Thanks for the great work. Is it possible to add a link inside the lightbox, either to say the data-title or data-desc. Or via another method?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.