Call fotorama gallery in full screen mode via API

北慕城南 提交于 2019-12-01 00:19:18

1. requestFullScreen()

Use Fotorama API call with prevented auto-initialization:

<script>
  $(function () {
    var fotorama = $('.fotorama')
      .fotorama({allowfullscreen: true})
      .data('fotorama');

    fotorama.requestFullScreen();
  });
</script>

<div class="fotorama"
     data-auto="false"
     data-height="100%">
  <img src="1.jpg">
  <img src="2.jpg">
</div>

But there will be a fullscreen-exit icon at the top-right, and users will be able to leave fullscreen. And even if you make the icon invisible, it will possible to close fullscreen by pressing esc button. So...


2. data-width="100%" data-height="100%"

I believe that it’s better to imitate fullscreen with this snippet:

<body style="margin: 0;">

  <div class="fotorama"
       data-width="100%"
       data-height="100%">
    <img src="1.jpg">
    <img src="2.jpg">
    <img src="3.jpg">
  </div>

</body>

Example: http://fotorama.io/examples/full-window.html.

tr_

I've wasted a lot of time trying to hide Fotorama block. Try to add class “fotorama--hidden”.

<div class="fotorama fotorama--hidden">
  <!-- images -->
</div>

This will hide the block but all functions from Art's answer #1 will work normally. And when you exit fullscreen Fotorama will just hide.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!