当前位置: 移动技术网 > IT编程>网页制作>CSS > longing加载中实例

longing加载中实例

2018年11月15日  | 移动技术网IT编程  | 我要评论

利用图片播放

<div class="wrap" id="wrap" style="position: inherit; height: 604px;">
    <div class="main">
        <script src="http://www.zaidu.sn.cn/zaidu/刺激战场争霸赛3/js/canvas.js"></script>
<div id="loading" class="compatiblestyle">
            <div id="startplay" style="display: none">开始刺激时刻</div>
            <canvas id="clgass" width="128" height="128"></canvas>
            <script>
            var frame_imgs_1=['run_1.png','run_2.png','run_3.png','run_4.png','run_5.png','run_6.png','run_7.png','run_8.png','run_9.png','run_10.png','run_11.png','run_12.png','run_13.png','run_14.png','run_15.png','run_16.png',];

            //新建动画实例
            var cfa1=new canvasfa({
                    cav:'clgass'//canvas画布id
                    ,frames:frame_imgs_1//帧动画的素材
                    ,url:'http://www.zaidu.sn.cn/demo/zaidu_03/img/'//图片路径
                    ,fps:24//【可选参数】每秒帧数,默认每秒15帧。(液晶屏每秒刷新60次,所以帧数最好是可以整除60的数)
                    ,loop:true//【可选参数】循环播放,false则单次播放并停留在最后一帧,true和默认是循环播放
                    //,autoplay:false//【可选参数】素材加载完毕后是否自动播放; false不播放,true和默认是自动播放。可用 实例对象.start()手动开启播放
                    //,loading_done:alert1//【可选参数】参数需要是一个函数,在素材加载完毕后运行。可缺省此参数。
                
            });
                
//开始            
var _pageheight = document.documentelement.clientheight,
    _pagewidth = document.documentelement.clientwidth;
//计算loading框距离顶部和左部的距离(loading框的宽度为215px,高度为61px)
var _loadingtop = _pageheight > 61 ? (_pageheight - 61) / 2 : 0,
    _loadingleft = _pagewidth > 215 ? (_pagewidth - 215) / 2 : 0;
//在页面未加载完毕之前显示的loading html自定义内容
var _loadinghtml = document.getelementbyid("clgass");
//呈现loading效果
                
                
/*'<div id="loadingdiv" style="position:absolute;left:0;width:100%;height:' + _pageheight + 'px;top:0;background:#f3f8ff;opacity:1;filter:alpha(opacity=80);z-index:10000;"><div style="position: absolute; cursor1: wait; left: ' + _loadingleft + 'px; top:' + _loadingtop + 'px; width: auto; height: 57px; line-height: 57px; padding-left: 50px; padding-right: 5px; background: #fff url(image/loading.gif) no-repeat scroll 5px 10px; border: 2px solid #95b8e7; color: #696969; font-family:\'microsoft yahei\';">页面加载中,请等待...</div></div>'*/
                
                
document.write(_loadinghtml);

//window.onload = function () {
//    var loadingmask = document.getelementbyid('loadingdiv');
//    loadingmask.parentnode.removechild(loadingmask);
//};

//监听加载状态改变
document.onreadystatechange = completeloading;

//加载状态为complete时移除loading效果
function completeloading() {
    if (document.readystate == "complete") {
        var loadingmask = document.getelementbyid('loading');
        loadingmask.parentnode.removechild(loadingmask);
    }
}    
</script>     
    </div>

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网