码迷,mamicode.com
首页 > Web开发 > 详细

图片预先加载 preloadjs

时间:2019-11-04 19:54:06      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:cti   java   sha   text   inf   create   on()   body   win   

<body>
<div class="loading">
<div class="progress"></div>
</div>
<img src="images/bg0.png" style="display: none"/> <img src="images/btn.png" style="display: none"/> <img src="images/fish1.png" style="display: none"/> <img src="images/fish2.png" style="display: none"/> <img src="images/img1.png" style="display: none"/> <img src="images/img2.png" style="display: none"/> <img src="images/img3.png" style="display: none"/> <img src="images/img5.png" style="display: none"/> <img src="images/leaf1.png" style="display: none"/> <img src="images/leaf2.png" style="display: none"/> <img src="images/page0_main_title_gong.png" style="display: none"/> <img src="images/page0_main_title_de.png" style="display: none"/> <img src="images/page0_main_title_wu.png" style="display: none"/> <img src="images/page0_main_title_liang.png" style="display: none"/> <img src="images/page0_water1.png" style="display: none"/> <img src="images/page0_water2.png" style="display: none"/> <img src="images/page0_water3.png" style="display: none"/> <img src="images/page0_yun_left1.png" style="display: none"/> <img src="images/page0_yun_right1.png" style="display: none"/> <img src="images/page0_yun_right2.png" style="display: none"/> <img src="images/page0_yun_right3.png" style="display: none"/>
<img src="images/img2.png" alt=" " style="display: none"><img src="images/img2_main.png" alt=" " style="display: none">
<div class="show_box">

</div>
</body>



<script type="text/javascript" src="js/jquery.min.js"></script> 

<script type="text/javascript" src="js/preloadjs-0.6.1.min.js"></script>

/******************************preloading start********************************/ var preload; var mainfest; // 初始化预加载manifest清单 function setupManifest(){ mainfest = [ { src:"images/bg0.png"} , { src:"images/btn.png"}, { src:"images/fish1.png"} , { src:"images/fish2.png"}, { src:"images/img1.png"} , { src:"images/img2.png"}, { src:"images/img3.png"} , { src:"images/img5.png"}, { src:"images/leaf1.png"} , { src:"images/leaf2.png"}, { src:"images/page0_main_title_de.png"} , { src:"images/page0_main_title_gong.png"}, { src:"images/page0_main_title_liang.png"} , { src:"images/page0_main_title_wu.png"}, { src:"images/page0_water1.png"} , { src:"images/page0_water2.png"}, { src:"images/page0_water3.png"} , { src:"images/page0_yun_left1.png"}, { src:"images/page0_yun_right1.png"} , { src:"images/page0_yun_right2.png"}, { src:"images/page0_yun_right3.png"} , { src:"images/page2_bg.png"}, { src:"images/water2.png"},{ src:"images/img2_main.png"} ]; } // 预加载函数 function startPreload() { preload = new createjs.LoadQueue(true); //注意加载音频文件需要调用如下代码行 preload.installPlugin(createjs.SOUND); //为preloaded添加整个队列变化时展示的进度事件 preload.addEventListener("progress",handleFileProgress); //为preloaded添加当队列完成全部加载后触发事件 preload.addEventListener("complete",loadComplete); //设置最大并发连接数 最大值为10 preload.setMaxConnections(1); preload.loadManifest(mainfest); } // 当整个队列变化时展示的进度事件的处理函数 function handleFileProgress(event) { $(".progress").text("loading..."+Math.ceil(event.loaded * 100)+ "%"); console.log(event.loaded); } // 处理preload添加当队列完成全部加载后触发事件 function loadComplete() { // 设置定时器,当全部加载完毕后让100%停留0.4秒,提高用户体验,不至于让用户感觉不到 window.setTimeout(()=>{ $(".loading").remove(); },400); $(".show_box").show(); gdx_animate(); setTimeout(function(){ location.href = ‘page1.html?fresh=1‘; },5000); } setupManifest(); startPreload(); /******************************preloading end********************************/

  

图片预先加载 preloadjs

标签:cti   java   sha   text   inf   create   on()   body   win   

原文地址:https://www.cnblogs.com/shirleyjiang/p/11793785.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!