Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/460.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Fotorama.io:如何通过帧对象数组延迟加载图像?_Javascript_Image_Loading_Lazy Evaluation_Fotorama - Fatal编程技术网

Javascript Fotorama.io:如何通过帧对象数组延迟加载图像?

Javascript Fotorama.io:如何通过帧对象数组延迟加载图像?,javascript,image,loading,lazy-evaluation,fotorama,Javascript,Image,Loading,Lazy Evaluation,Fotorama,我有以下代码,可以通过帧对象数组加载图像: localFotorama1.load([ {img: '1.jpg', caption: '1st image'}, {img: '2.jpg', caption: '2nd image'}, {img: '3.jpg', caption: '3rd image'}, {img: '4.jpg', caption: '4th image'}, {img: '5.jpg', caption: '5th image'} ]); 我在

我有以下代码,可以通过帧对象数组加载图像:

localFotorama1.load([
  {img: '1.jpg', caption: '1st image'},
  {img: '2.jpg', caption: '2nd image'},
  {img: '3.jpg', caption: '3rd image'},
  {img: '4.jpg', caption: '4th image'},
  {img: '5.jpg', caption: '5th image'}
]);
我在页面完全初始化后使用它,根据屏幕或窗口宽度加载不同大小的图像。我只是在HTML中用一个小的空白图像初始化Fotorama,然后在以后动态地重新加载图像

但是,我相信这将立即加载所有图像,因为它们是“img”标记,因此可能与此等效:

<div class="fotorama">
  <img src="1.jpg">
  <img src="2.jpg">
</div>

对于小型设备上的延迟加载,如何在帧对象数组中实现以下等效功能:

<div class="fotorama">
  <a href="1.jpg"></a>
  <a href="2.jpg"></a>
</div>

我想我应该使用“html:”标记,并且至少尝试了以下两种方法:

localFotorama1.load([
  {html: '<div><a href="1.jpg"></a></div>', caption: '1st image'},
  ...
]);
localFotorama1.load([
{html:'',标题:'1st image'},
...
]);
而且

localFotorama1.load([
  {html: '<a href="1.jpg"></a>', caption: '1st image'},
  ...
]);
localFotorama1.load([
{html:'',标题:'1st image'},
...
]);
。。。它们之间的唯一区别是在“
”周围有一个“
”包装器:

{
img:'1.jpg',
thumb:'1-thumb.jpg',
full:'1-full.jpg',//全屏模式的单独图像。
视频:'http://youtu.be/C3lWwBslWqg“,//Youtube、Vimeo或自定义iframe URL
id:'one',//自定义锚点与hash:true选项一起使用。
标题:“第一个标题”,
html:$('selector')、//…或'123'。框架内的自定义html。
拟合:“cover”,//覆盖全局拟合选项。
any:“与要存储的帧相关的任何数据”
}
有什么建议吗


谢谢!

别担心,你做得很好!当你使用
load
方法时,懒散加载工作很好。请看演示视频:

谢谢你的快速回复,但我有点困惑…你是说懒散加载与load方法和img标记是自动的吗?我的开发人员资源读数没有显示相同的活动。…它显示从一开始加载的所有图像。是因为我使用的是缩略图,而没有声明单独的缩略图吗?哦…现在我明白了。再次感谢您的回复!
{
  img: '1.jpg',
  thumb: '1-thumb.jpg',
  full: '1-full.jpg', // Separate image for the fullscreen mode.
  video: 'http://youtu.be/C3lWwBslWqg', // Youtube, Vimeo or custom iframe URL
  id: 'one', // Custom anchor is used with the hash:true option.
  caption: 'The first caption',
  html: $('selector'), // ...or '<div>123</div>'. Custom HTML inside the frame.
  fit: 'cover', // Override the global fit option.
  any: 'Any data relative to the frame you want to store'
}