如何用代码让lightgallery进入全屏模式?

How to make lightgallery enter full screen mode with code?

我想通过函数调用让 lightGallery ( https://github.com/sachinchoolur/lightGallery.git ) 自动进入全屏模式。
但我找不到让它工作的方法。
请帮助我。

这是我的代码

$("#preview").lightGallery({
    fullScreen: true
});

// TODO: I want automatic enter full screen mode by code here ( same with click on thumbnail image )
console.log('I want automatic enter full screen mode here');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.6.12/css/lightgallery.min.css" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.6.12/js/lightgallery-all.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lg-fullscreen/1.1.0/lg-fullscreen.min.js"></script>

<div id="preview">
  <a href="https://sachinchoolur.github.io/lightgallery.js/static/img/1.jpg">
    <img src="https://sachinchoolur.github.io/lightgallery.js/static/img/thumb-1.jpg">
  </a>
</div>

如果您希望图像在页面加载时自动打开,您可以通过向 img 元素添加一个 id 属性并向其添加一个 click 事件来实现它,就像这样:

HTML:

<div id="preview">
  <a href="https://sachinchoolur.github.io/lightgallery.js/static/img/1.jpg">
    <img id="gallery" src="https://sachinchoolur.github.io/lightgallery.js/static/img/thumb-1.jpg">
  </a>
</div>

JS:

$("#preview").lightGallery({
    fullScreen: true
});

$('#gallery').click()

你可以检查这个working code sample