gpt4 book ai didi

jQuery 循环延迟加载

转载 作者:行者123 更新时间:2023-12-03 23:04:41 25 4
gpt4 key购买 nike

我有一个 jQuery 循环演示页面,其中包含大约 48 张幻灯片。问题是所有资源的初始加载需要一段时间,因此页面看起来会扭曲大约 1-5 秒。有没有办法仅在调用幻灯片或已知幻灯片是上一张或下一张幻灯片时延迟加载每张幻灯片所需的资源?

最佳答案

jquery Cycle2 插件允许渐进式加载: http://jquery.malsup.com/cycle2/demo/progressive.php

<div class="cycle-slideshow auto" 
data-cycle-fx="scrollHorz"
data-cycle-timeout="2000"
data-cycle-caption=".caption1"
data-cycle-caption-template="{{slideNum}} / 9"
data-cycle-loader="true"
data-cycle-progressive="#images"
>
<!-- only one image declared in markup -->
<img src="http://jquery.malsup.com/cycle2/images/beach1.jpg">

<!--
JSON array of slides to be loaded progressively,
nested inside a script block. The script block does not need
to be inslide the slideshow container, it can be anywhere on the
page. Note the type on the script tag.
-->
<script id="images" type="text/cycle">
[
"<img src='http://jquery.malsup.com/cycle2/images/beach2.jpg'>",
"<img src='http://jquery.malsup.com/cycle2/images/beach3.jpg'>",
...
"<img src='http://jquery.malsup.com/cycle2/images/beach9.jpg'>"
]
</script>
</div>
<div class="center caption1"></div>

关于jQuery 循环延迟加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12283442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com