0

I am not able to listen to event fotorama:fullscreenenter what I've tried:

<script type="text/javascript">
    require(['jquery', 'mage/gallery/gallery'], function($, gallery){
        $('[data-gallery-role=gallery-placeholder]').on('gallery:loaded', function () {
            console.log('this works!')
            $(this).on('fotorama:ready', function(){
                console.log('this also works!');
            });
            $(this).on('fotorama:fullscreenenter', function(){
                console.log('THIS DOESN\'T WORK!')
            });
        });
        $('[data-gallery-role="gallery"]').on('fotorama:fullscreenenter', function() {
            console.log('THIS ALSO DOESN\'T WORK!'); //Taken from ../magento2-base/lib/web/mage/gallery/gallery.js lines #184, #191
        });
        $(this).on('gallery:fullscreenenter', function () {
           console.log('ALSO DOESN\T WORK!');
        })
    });
</script>
1

I've got it!

inside the gallery:loaded i can now listen to event fullscreenenter when fullscreen mode shows when image is clicked essentially like so:

...
var item = $(document).find('.fotorama-item');
console.log(item);
item.on('fotorama:fullscreenenter',function () {
     console.log('okokokokkokko');
})
...
| improve this answer | |
0

Thank you for the solution! That works! I suggest using "this" instead of "document" to select the fotorama-item. Could get you into trouble if there are multiple galleries on the page.

...
var item = $(this).find('.fotorama-item');
item.on('fotorama:fullscreenenter',function () {
    console.log('OK');
}); 
...
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.