5

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.

Ronak Chauhan
6,2133 gold badges31 silver badges67 bronze badges
asked Dec 22, 2016 at 6:04
4
  • may be you have to use this.openFullScreen() instead of gallery.openFullScreen(); Commented Dec 22, 2016 at 6:06
  • @Rakesh I am getting TypeError: this.openFullScreen is not a function Commented Dec 22, 2016 at 6:22
  • try with this ,var self = this; self.openFullScreen(); Commented Dec 22, 2016 at 6:23
  • @Rakesh throwing same error, i am adding external string, 'self' may not help. Commented Dec 22, 2016 at 6:27

2 Answers 2

7

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);
 
 });
});
Zudian
3582 silver badges7 bronze badges
answered Dec 27, 2016 at 12:56
3
  • Do you know how I can check which is the current slide it's on? Yours will always open the first one as is. Commented Dec 4, 2018 at 8:24
  • You are recreating the fotorama instance by doing this. Magento looses it and cannot control it anymore after that. Commented Mar 28, 2019 at 12:58
  • But close button can't display in fullscreen. Have an any idea? Commented May 31, 2019 at 12:37
1

You can also do this and trigger Magento 2's native behavior:

$('.fotorama__stage__frame').trigger('mouseup');
answered Feb 13, 2019 at 8:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.