File tree 7 files changed +12
-46
lines changed
7 files changed +12
-46
lines changed Original file line number Diff line number Diff line change @@ -209,10 +209,6 @@ The following options are available:
209
209
210
210
``` js
211
211
{
212
- // Load the lightbox empty if no elements are available
213
- // (e.g. when elements are loaded via Ajax)
214
- loadEmpty: false ,
215
-
216
212
// Selector for elements that trigger Parvus
217
213
selector: ' .lightbox' ,
218
214
Original file line number Diff line number Diff line change @@ -117,7 +117,6 @@ function Parvus(userOptions) {
117
117
const mergeOptions = userOptions => {
118
118
// Default options
119
119
const DEFAULT_OPTIONS = {
120
- loadEmpty : false ,
121
120
selector : '.lightbox' ,
122
121
gallerySelector : null ,
123
122
captions : true ,
@@ -189,8 +188,9 @@ function Parvus(userOptions) {
189
188
* @param {HTMLElement } el - The element to be added
190
189
*/
191
190
const add = el => {
191
+ // Check if the lightbox already exists
192
192
if ( ! lightbox ) {
193
- return ;
193
+ createLightbox ( ) ;
194
194
}
195
195
if ( ! ( el . tagName === 'A' && el . hasAttribute ( 'href' ) || el . tagName === 'BUTTON' && el . hasAttribute ( 'data-target' ) ) ) {
196
196
throw new Error ( 'Use a link with the \'href\' attribute or a button with the \'data-target\' attribute. Both attributes must contain a path to the image file.' ) ;
@@ -1395,17 +1395,7 @@ function Parvus(userOptions) {
1395
1395
const init = ( ) => {
1396
1396
// Merge user options into defaults
1397
1397
config = mergeOptions ( userOptions ) ;
1398
-
1399
- // Check if the lightbox should be loaded empty or if there are elements for the lightbox.
1400
- if ( ! config . loadEmpty && ! document . querySelectorAll ( config . selector ) . length ) {
1401
- return ;
1402
- }
1403
1398
reducedMotionCheck ( ) ;
1404
-
1405
- // Check if the lightbox already exists
1406
- if ( ! lightbox ) {
1407
- createLightbox ( ) ;
1408
- }
1409
1399
if ( config . gallerySelector !== null ) {
1410
1400
// Get a list of all `gallerySelector` elements within the document
1411
1401
const GALLERY_ELS = document . querySelectorAll ( config . gallerySelector ) ;
Original file line number Diff line number Diff line change 123
123
const mergeOptions = userOptions => {
124
124
// Default options
125
125
const DEFAULT_OPTIONS = {
126
- loadEmpty : false ,
127
126
selector : '.lightbox' ,
128
127
gallerySelector : null ,
129
128
captions : true ,
195
194
* @param {HTMLElement } el - The element to be added
196
195
*/
197
196
const add = el => {
197
+ // Check if the lightbox already exists
198
198
if ( ! lightbox ) {
199
- return ;
199
+ createLightbox ( ) ;
200
200
}
201
201
if ( ! ( el . tagName === 'A' && el . hasAttribute ( 'href' ) || el . tagName === 'BUTTON' && el . hasAttribute ( 'data-target' ) ) ) {
202
202
throw new Error ( 'Use a link with the \'href\' attribute or a button with the \'data-target\' attribute. Both attributes must contain a path to the image file.' ) ;
1401
1401
const init = ( ) => {
1402
1402
// Merge user options into defaults
1403
1403
config = mergeOptions ( userOptions ) ;
1404
-
1405
- // Check if the lightbox should be loaded empty or if there are elements for the lightbox.
1406
- if ( ! config . loadEmpty && ! document . querySelectorAll ( config . selector ) . length ) {
1407
- return ;
1408
- }
1409
1404
reducedMotionCheck ( ) ;
1410
-
1411
- // Check if the lightbox already exists
1412
- if ( ! lightbox ) {
1413
- createLightbox ( ) ;
1414
- }
1415
1405
if ( config . gallerySelector !== null ) {
1416
1406
// Get a list of all `gallerySelector` elements within the document
1417
1407
const GALLERY_ELS = document . querySelectorAll ( config . gallerySelector ) ;
Original file line number Diff line number Diff line change @@ -53,7 +53,6 @@ export default function Parvus (userOptions) {
53
53
const mergeOptions = ( userOptions ) => {
54
54
// Default options
55
55
const DEFAULT_OPTIONS = {
56
- loadEmpty : false ,
57
56
selector : '.lightbox' ,
58
57
gallerySelector : null ,
59
58
captions : true ,
@@ -131,8 +130,9 @@ export default function Parvus (userOptions) {
131
130
* @param {HTMLElement } el - The element to be added
132
131
*/
133
132
const add = ( el ) => {
133
+ // Check if the lightbox already exists
134
134
if ( ! lightbox ) {
135
- return
135
+ createLightbox ( )
136
136
}
137
137
138
138
if ( ! ( ( el . tagName === 'A' && el . hasAttribute ( 'href' ) ) || ( el . tagName === 'BUTTON' && el . hasAttribute ( 'data-target' ) ) ) ) {
@@ -1459,18 +1459,8 @@ export default function Parvus (userOptions) {
1459
1459
// Merge user options into defaults
1460
1460
config = mergeOptions ( userOptions )
1461
1461
1462
- // Check if the lightbox should be loaded empty or if there are elements for the lightbox.
1463
- if ( ! config . loadEmpty && ! document . querySelectorAll ( config . selector ) . length ) {
1464
- return
1465
- }
1466
-
1467
1462
reducedMotionCheck ( )
1468
1463
1469
- // Check if the lightbox already exists
1470
- if ( ! lightbox ) {
1471
- createLightbox ( )
1472
- }
1473
-
1474
1464
if ( config . gallerySelector !== null ) {
1475
1465
// Get a list of all `gallerySelector` elements within the document
1476
1466
const GALLERY_ELS = document . querySelectorAll ( config . gallerySelector )
Original file line number Diff line number Diff line change @@ -36,25 +36,25 @@ setTimeout(() => {
36
36
* Events
37
37
*
38
38
*/
39
- prvs . on ( 'open' , function ( event ) {
39
+ prvs . on ( 'open' , ( event ) => {
40
40
console . log ( `
41
41
Opened by: ${ event . detail . source }
42
42
at index: ${ prvs . currentIndex ( ) } ,
43
43
selected slide: ${ prvs . currentIndex ( ) + 1 }
44
44
` )
45
45
} )
46
46
47
- prvs . on ( 'select' , function ( ) {
47
+ prvs . on ( 'select' , ( ) => {
48
48
console . log ( `
49
49
Selected index: ${ prvs . currentIndex ( ) } ,
50
50
selected slide: ${ prvs . currentIndex ( ) + 1 }
51
51
` )
52
52
} )
53
53
54
- prvs . on ( 'close' , function ( ) {
54
+ prvs . on ( 'close' , ( ) => {
55
55
console . log ( 'Closed' )
56
56
} )
57
57
58
- prvs . on ( 'destroy' , function ( ) {
58
+ prvs . on ( 'destroy' , ( ) => {
59
59
console . log ( 'Destroyed' )
60
60
} )
You can’t perform that action at this time.
0 commit comments