Toggle class by opening gallery

Hello
I want to toggle a class, if lightgallery opens. They provide this code:



    var $lg = $('#lightgallery');
     
    $lg.lightGallery();
     
    // Perform any action just before opening the gallery
    $lg.on('onBeforeOpen.lg',function(event){
        alert('onBeforeOpen');
    });
     
    // custom event with extra parameters 
    // index - index of the slide
    // fromTouch - true if slide function called via touch event or mouse drag
    // fromThumb - true if slide function called via thumbnail click
    $lg.on('onBeforeSlide.lg',function(event, index, fromTouch, fromThumb){
        console.log(index, fromTouch, fromThumb);
    });

I have this js to toggle my classes by click:

 $(function() {
	
 $("#kuenstler").click(function(){
   $("body").toggleClass("scrolled-down-20"); }).scroll();
 });

Now I want to combine these 2 that my classes are toggled by opening the gallery.

Thanks for help.
snote

so you’ve got a block that says “Perform any action just before opening the gallery”, and a block that has a line in it that toggles your class…and you want to combine those two…

I want the toggling to be fired before opening the gallery.

Here is wild idea. How about

$lg.on('onBeforeOpen.lg',function(event){
    $("body").toggleClass("scrolled-down-20"); }).scroll();
});

???

No, Sorry. Not working.
I also tried lots of those variations, but was unlucky until now.
But thanks a lot for the idea!
snote

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.