UNPKG

7.11 kBMarkdownView Raw
1![commit](https://badgen.net/github/last-commit/sachinchoolur/lightGallery/master)
2![npm](https://img.shields.io/npm/v/lightgallery.svg?color=red)
3![npm-tag](https://badgen.net/github/tag/sachinchoolur/lightgallery)
4![size](https://badgen.net/bundlephobia/minzip/lightgallery?color=cyan)
5![tree-shaking](https://badgen.net/bundlephobia/tree-shaking/lightgallery?color=purple)
6![types](https://badgen.net/npm/types/lightgallery?color=blue)
7![hits](https://badgen.net/jsdelivr/hits/npm/lightgallery?color=pink)
8
9# lightGallery
10
11A customizable, modular, responsive, lightbox gallery plugin. No dependencies.\\
12Available for React.js, Angular, Vue.js, and typescript.
13
14![lightgallery](https://www.lightgalleryjs.com/lightgallery-demo.png)
15
16## Core features
17
18- Fully responsive.
19- Modular architecture with built in plugins.
20- Highly optimized for touch devices.
21- Mouse drag supports for desktops.
22- Double-click/Double-tap to see actual size of the image.
23- Animated thumbnails.
24- Social sharing.
25- YouTube Vimeo Wistia and html5 videos Support.
26- 20+ Hardware-Accelerated CSS3 transitions.
27- Dynamic mode.
28- Inline gallery.
29- Full screen support.
30- Zoom in/out, Pinch to zoom.
31- Swipe/Drag up/down support to close gallery.
32- Browser history API(deep linking).
33- Responsive images.
34- HTML iframe support.
35- Multiple instances on one page.
36- Easily customizable via CSS (SCSS) and Settings.
37- Smart image preloading and code optimization.
38- Keyboard Navigation for desktop.
39- SVG icons.
40- Accessibility support.
41- Rotate, flip images.
42- And many more.
43
44## Documentation
45
46- [Getting started](https://www.lightgalleryjs.com/docs/getting-started/)
47- [Settings](https://www.lightgalleryjs.com/docs/settings/)
48- [React](https://www.lightgalleryjs.com/docs/react/)
49- [Vue.js](https://www.lightgalleryjs.com/docs/vue/)
50- [Angular](https://www.lightgalleryjs.com/docs/angular/)
51- [Demos](https://www.lightgalleryjs.com/demos/thumbnails/)
52- [CodePen](https://codepen.io/collection/BNNjpR)
53
54## Installation
55
56lightGallery is available on NPM, Yarn, Bower, CDNs, and GitHub. You can use any
57of the following method to download lightGallery.
58
59- [NPM](https://www.npmjs.com/) - NPM is a package manager for the JavaScript
60 programming language. You can install `lightgallery` using the following
61 command
62
63 ```sh
64 npm install lightgallery
65 ```
66
67- [YARN](https://yarnpkg.com/) - Yarn is another popular package manager for
68 the JavaScript programming language. If you prefer you can use Yarn instead
69 of NPM
70
71 ```sh
72 yarn add lightgallery
73 ```
74
75- [Bower](http://bower.io) - You can find lightGallery on Bower package
76 manager as well
77
78 ```sh
79 bower install lightgallery --save
80 ```
81
82- [GitHub](https://github.com/sachinchoolur/lightGallery/archive/master.zip) -
83 You can also directly download lightgallery from GitHub
84
85- CDN - If you prefer to use a CDN, you can load files via
86 [jsdelivr](https://www.jsdelivr.com/projects/lightgallery),
87 [cdnjs](https://cdnjs.com/libraries/lightgallery) or
88 [unpkg](https://unpkg.com/browse/lightgallery@latest/)
89
90#### Include CSS and Javascript files
91
92First of all, include lightgallery.css in the <head> of the document. If
93you want include any lightGallery plugin such as thumbnails or zoom, you need to
94include respective css files as well.
95
96Alternatively you can include `lightgallery-bundle.css` which contains
97lightGallery and all plugin styles instead of separate stylesheets.
98
99If you like you can also import scss files instead of css files from the `scss`
100folder.
101
102```HTML
103<head>
104 <link type="text/css" rel="stylesheet" href="css/lightgallery.css" />
105
106 <!-- lightgallery plugins -->
107 <link type="text/css" rel="stylesheet" href="css/lg-zoom.css" />
108 <link type="text/css" rel="stylesheet" href="css/lg-thumbnail.css" />
109
110
111 <!-- OR -->
112
113 <link type="text/css" rel="stylesheet" href="css/lightgallery-bundle.css" />
114</head>
115```
116
117Then include lightgallery.umd.js into your document. If you want to include any
118lightgallery plugin you can include it after lightgallery.umd.js.
119
120```HTML
121<body>
122 ....
123
124 <script src="js/lightgallery.umd.js"></script>
125
126 <!-- lightgallery plugins -->
127 <script src="js/plugins/lg-thumbnail.umd.js"></script>
128 <script src="js/plugins/lg-zoom.umd.js"></script>
129</body>
130```
131
132lightGallery supports AMD, CommonJS and ES6 modules too.
133
134```JavaScript
135import lightGallery from 'lightgallery';
136
137// Plugins
138import lgThumbnail from 'lightgallery/plugins/thumbnail'
139import lgZoom from 'lightgallery/plugins/zoom'
140
141```
142
143#### The markup
144
145lightgallery does not force you to use any kind of markup. you can use whatever
146markup you want.
147<a href="https://www.lightgalleryjs.com/demos/html-markup/">Here</a> can find
148detailed examples of different kinds of markups.
149
150If you know the original size of the media, you can pass it via
151`data-lg-size="${width}-${height}"` attribute for the initial
152[zoom](https://www.lightgalleryjs.com/docs/settings/#zoomFromOrigin) animation.
153But, this is completely optional.
154
155```HTML
156<div id="lightgallery">
157 <a href="img/img1.jpg" data-lg-size="1600-2400">
158 <img alt=".." src="img/thumb1.jpg" />
159 </a>
160 <a href="img/img2.jpg" data-lg-size="1024-800">
161 <img alt=".." src="img/thumb2.jpg" />
162 </a>
163 ...
164</div>
165```
166
167#### Initialize lightGallery
168
169Finally, you need to initiate the gallery by adding the following code.
170
171```javascript
172<script type="text/javascript">
173 lightGallery(document.getElementById('lightgallery'), {
174 plugins: [lgZoom, lgThumbnail],
175 speed: 500,
176 licenseKey: 'your_license_key'
177 ... other settings
178 });
179</script>
180```
181
182[CodePen Demos](https://codepen.io/collection/BNNjpR)
183
184#### License Key
185
186You'll receive a license key via email one you purchase a license [More info](https://www.lightgalleryjs.com/docs/settings/#licenseKey)
187
188#### Plugins
189
190As shown above, you need to pass the plugins via settings if you want to use any
191lightGallery plugins.
192
193If you are including lightGallery files via script tag, please use the same
194plugins names as follows.
195
196`lgZoom`, `lgAutoplay`, ` lgComment`, `lgFullscreen `, `lgHash`, `lgPager`,
197`lgRotate`, `lgShare`, `lgThumbnail`, `lgVideo`, `lgMediumZoom`
198
199## Browser support
200
201lightGallery supports all major browsers including IE 10 and above.
202
203## License
204
205#### Commercial license
206
207If you want to use lightGallery to develop commercial sites, themes, projects,
208and applications, the Commercial license is the appropriate license. With this
209option, your source code is kept proprietary.
210[Read more about the commercial license](https://www.lightgalleryjs.com/license/)
211
212#### Open source license
213
214If you are creating an open source application under a license compatible with
215the GNU GPL license v3, you may use this project under the terms of the GPLv3.
216
217## Support
218
219If you have any questions, suggestions, feedback, please reach out to [contact@lightgalleryjs.com](mailto:contact@lightgalleryjs.com) or DM me on [twitter](https://twitter.com/SachinNeravath)