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.
-
may be you have to use this.openFullScreen() instead of gallery.openFullScreen();Rakesh Jesadiya– Rakesh Jesadiya2016年12月22日 06:06:45 +00:00Commented Dec 22, 2016 at 6:06
-
@Rakesh I am getting TypeError: this.openFullScreen is not a functionKrishna ijjada– Krishna ijjada2016年12月22日 06:22:41 +00:00Commented Dec 22, 2016 at 6:22
-
try with this ,var self = this; self.openFullScreen();Rakesh Jesadiya– Rakesh Jesadiya2016年12月22日 06:23:51 +00:00Commented Dec 22, 2016 at 6:23
-
@Rakesh throwing same error, i am adding external string, 'self' may not help.Krishna ijjada– Krishna ijjada2016年12月22日 06:27:36 +00:00Commented Dec 22, 2016 at 6:27
2 Answers 2
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);
});
});
-
Do you know how I can check which is the current slide it's on? Yours will always open the first one as is.Gezzasa– Gezzasa2018年12月04日 08:24:14 +00:00Commented 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.Yonn Trimoreau– Yonn Trimoreau2019年03月28日 12:58:15 +00:00Commented Mar 28, 2019 at 12:58
-
But close button can't display in fullscreen. Have an any idea?Dhaduk Mitesh– Dhaduk Mitesh2019年05月31日 12:37:35 +00:00Commented May 31, 2019 at 12:37
You can also do this and trigger Magento 2's native behavior:
$('.fotorama__stage__frame').trigger('mouseup');
Explore related questions
See similar questions with these tags.