Magento 2: How to Trigger self.openFullScreen() in Custom jQuery on Product Details Page

jquerymagento2product-viewrequirejs

If we click on product image in the product details page, gallery full screen is coming to see the images in full screen.

I am trying to get the same functionality when click on my string Quick view in product details page added as an extension.

I have done so far:

I have added the below code in my template.

<span id="see_thumbnails" >Quick view</span>                      

<script type="text/javascript">
    require([
    'jquery',
    'mage/gallery/gallery'
], function ($, gallery) {
    'use strict';
        $("#see_thumbnails").on("click" ,function() {

            gallery.openFullScreen();

        });

    });
</script>

I am using openFullScreen because i found openFullScreen related code at vendor\magento\magento2-base\lib\web\mage\gallery\gallery.js

Can any one tell me where i am doing wrong.

Help would be appreciated.

Best Answer

After spending some time, i found the answer as mentioned below, hope this will help for someone.

    <script type="text/javascript">
        require([
        'jquery',
        'fotorama/fotorama'
    ], function ($, fotorama) {
        'use strict';
        
    
            $("#see_thumbnails").on("click" ,function() {       
    
                 var fotorama = $('.fotorama').fotorama({allowfullscreen: true}).data('fotorama');
                 fotorama.requestFullScreen();
                 var $fotoramaDiv = $('.fotorama').fotorama();
                 $fotoramaDiv.data('fotorama').show(0);
                 
            });
});