File tree 7 files changed +29
-59
lines changed
7 files changed +29
-59
lines changed Original file line number Diff line number Diff line change @@ -300,14 +300,6 @@ The following events are available:
300
300
| ` close ` | Triggered after Parvus has been closed |
301
301
| ` destroy ` | Triggered after Parvus has been destroyed |
302
302
303
- Except for the ` close ` and ` destroy ` events, you can access the current source element using the ` event.detail.source ` property.
304
-
305
- ``` js
306
- prvs .on (' open' , function (event ) {
307
- console .log (event .detail .source );
308
- })
309
- ```
310
-
311
303
## Browser Support
312
304
313
305
Parvus is supported on the latest versions of the following browsers:
Original file line number Diff line number Diff line change @@ -465,9 +465,7 @@ function Parvus(userOptions) {
465
465
preload ( currentIndex - 1 ) ;
466
466
467
467
// Create and dispatch a new event
468
- fire ( 'open' , {
469
- source : el
470
- } ) ;
468
+ dispatchCustomEvent ( 'open' ) ;
471
469
} ;
472
470
473
471
/**
@@ -742,11 +740,7 @@ function Parvus(userOptions) {
742
740
updateCounter ( ) ;
743
741
744
742
// Create and dispatch a new event
745
- fire ( 'select' , {
746
- detail : {
747
- source : GROUPS [ activeGroup ] . triggerElements [ currentIndex ]
748
- }
749
- } ) ;
743
+ dispatchCustomEvent ( 'select' ) ;
750
744
} ;
751
745
752
746
/**
@@ -1313,7 +1307,7 @@ function Parvus(userOptions) {
1313
1307
LIGHTBOX_TRIGGER_ELS . forEach ( remove ) ;
1314
1308
1315
1309
// Create and dispatch a new event
1316
- fire ( 'destroy' ) ;
1310
+ dispatchCustomEvent ( 'destroy' ) ;
1317
1311
} ;
1318
1312
1319
1313
/**
@@ -1347,11 +1341,9 @@ function Parvus(userOptions) {
1347
1341
* Dispatch a custom event
1348
1342
*
1349
1343
* @param {String } type - The type of the event to dispatch
1350
- * @param {Function } event - The event object
1351
1344
*/
1352
- const fire = ( type , event = { } ) => {
1345
+ const dispatchCustomEvent = type => {
1353
1346
const CUSTOM_EVENT = new CustomEvent ( type , {
1354
- detail : event ,
1355
1347
cancelable : true
1356
1348
} ) ;
1357
1349
lightbox . dispatchEvent ( CUSTOM_EVENT ) ;
Original file line number Diff line number Diff line change 471
471
preload ( currentIndex - 1 ) ;
472
472
473
473
// Create and dispatch a new event
474
- fire ( 'open' , {
475
- source : el
476
- } ) ;
474
+ dispatchCustomEvent ( 'open' ) ;
477
475
} ;
478
476
479
477
/**
748
746
updateCounter ( ) ;
749
747
750
748
// Create and dispatch a new event
751
- fire ( 'select' , {
752
- detail : {
753
- source : GROUPS [ activeGroup ] . triggerElements [ currentIndex ]
754
- }
755
- } ) ;
749
+ dispatchCustomEvent ( 'select' ) ;
756
750
} ;
757
751
758
752
/**
1319
1313
LIGHTBOX_TRIGGER_ELS . forEach ( remove ) ;
1320
1314
1321
1315
// Create and dispatch a new event
1322
- fire ( 'destroy' ) ;
1316
+ dispatchCustomEvent ( 'destroy' ) ;
1323
1317
} ;
1324
1318
1325
1319
/**
1353
1347
* Dispatch a custom event
1354
1348
*
1355
1349
* @param {String } type - The type of the event to dispatch
1356
- * @param {Function } event - The event object
1357
1350
*/
1358
- const fire = ( type , event = { } ) => {
1351
+ const dispatchCustomEvent = type => {
1359
1352
const CUSTOM_EVENT = new CustomEvent ( type , {
1360
- detail : event ,
1361
1353
cancelable : true
1362
1354
} ) ;
1363
1355
lightbox . dispatchEvent ( CUSTOM_EVENT ) ;
Original file line number Diff line number Diff line change @@ -445,9 +445,7 @@ export default function Parvus (userOptions) {
445
445
preload ( currentIndex - 1 )
446
446
447
447
// Create and dispatch a new event
448
- fire ( 'open' , {
449
- source : el
450
- } )
448
+ dispatchCustomEvent ( 'open' )
451
449
}
452
450
453
451
/**
@@ -775,11 +773,7 @@ export default function Parvus (userOptions) {
775
773
updateCounter ( )
776
774
777
775
// Create and dispatch a new event
778
- fire ( 'select' , {
779
- detail : {
780
- source : GROUPS [ activeGroup ] . triggerElements [ currentIndex ]
781
- }
782
- } )
776
+ dispatchCustomEvent ( 'select' )
783
777
}
784
778
785
779
/**
@@ -1375,7 +1369,7 @@ export default function Parvus (userOptions) {
1375
1369
LIGHTBOX_TRIGGER_ELS . forEach ( remove )
1376
1370
1377
1371
// Create and dispatch a new event
1378
- fire ( 'destroy' )
1372
+ dispatchCustomEvent ( 'destroy' )
1379
1373
}
1380
1374
1381
1375
/**
@@ -1409,11 +1403,9 @@ export default function Parvus (userOptions) {
1409
1403
* Dispatch a custom event
1410
1404
*
1411
1405
* @param {String } type - The type of the event to dispatch
1412
- * @param {Function } event - The event object
1413
1406
*/
1414
- const fire = ( type , event = { } ) => {
1407
+ const dispatchCustomEvent = ( type ) => {
1415
1408
const CUSTOM_EVENT = new CustomEvent ( type , {
1416
- detail : event ,
1417
1409
cancelable : true
1418
1410
} )
1419
1411
Original file line number Diff line number Diff line change 1
1
/**
2
- * Import language file
2
+ * Import Parvus
3
3
*
4
4
*/
5
5
import Parvus from '../dist/js/parvus.esm.min.js'
6
+
7
+ /**
8
+ * Import language file
9
+ *
10
+ */
6
11
import de from '../src/l10n/de.js'
7
12
8
13
/**
@@ -36,25 +41,22 @@ setTimeout(() => {
36
41
* Events
37
42
*
38
43
*/
39
- prvs . on ( 'open' , ( event ) => {
40
- console . log ( `
41
- Opened by: ${ event . detail . source }
42
- at index: ${ prvs . currentIndex ( ) } ,
43
- selected slide: ${ prvs . currentIndex ( ) + 1 }
44
- ` )
44
+ prvs . on ( 'open' , ( ) => {
45
+ console . log ( `Open:
46
+ Index: ${ prvs . currentIndex ( ) } ,
47
+ Slide: ${ prvs . currentIndex ( ) + 1 } ` )
45
48
} )
46
49
47
50
prvs . on ( 'select' , ( ) => {
48
- console . log ( `
49
- Selected index: ${ prvs . currentIndex ( ) } ,
50
- selected slide: ${ prvs . currentIndex ( ) + 1 }
51
- ` )
51
+ console . log ( `Select:
52
+ Index: ${ prvs . currentIndex ( ) } ,
53
+ Slide: ${ prvs . currentIndex ( ) + 1 } ` )
52
54
} )
53
55
54
56
prvs . on ( 'close' , ( ) => {
55
- console . log ( 'Closed ' )
57
+ console . log ( 'Close ' )
56
58
} )
57
59
58
60
prvs . on ( 'destroy' , ( ) => {
59
- console . log ( 'Destroyed ' )
61
+ console . log ( 'Destroy ' )
60
62
} )
You can’t perform that action at this time.
0 commit comments