首页 > 其他 > 详细

假性进度效果

时间:2015-11-06 10:54:48      阅读:205      评论:0      收藏:0      [点我收藏+]

var image1=new Image();

var loadi=0

var loadtime=null;

function pageload(){
loadi++;
if(loadi==1){
var canvas = document.getElementById("adCanvas");

image1=image;

if(image1.width > 200) {
// 宽度等比例缩放 *=
image1.height =image1.height*200 / image1.width;
image1.width = 200;
}

$("#fgbox").css("width",image1.width);
$("#fgbox").css("height",image1.height);

var ctx = canvas.getContext("2d");
// canvas清屏
ctx.clearRect(0, 0, canvas.width, canvas.height);
// 重置canvas宽高
canvas.width = image1.width;
canvas.height = image1.height;
// 将图像绘制到canvas上
ctx.drawImage(image1, 0, 0, image1.width, image1.height);

$("#adcbox").css("display","block");
loadtime=setTimeout(‘pageload()‘,100);
}
if(loadi<20){
var h = image1.height*(100-loadi)/100;
$("#fgbox").css("height",h);
loadtime=setTimeout(‘pageload()‘,600);
$("#loadnum").html(loadi+‘%‘);
}else if(loadi<50){
var h = image1.height*(100-loadi)/100;
$("#fgbox").css("height",h);
loadtime=setTimeout(‘pageload()‘,400);
$("#loadnum").html(loadi+‘%‘);
}else if(loadi<90){
var h = image1.height*(100-loadi)/100;
loadtime=$("#fgbox").css("height",h);
setTimeout(‘pageload()‘,500);
$("#loadnum").html(loadi+‘%‘);
}else if(loadi<100){
var h = image1.height*(100-loadi)/100;
loadtime=$("#fgbox").css("height",h);
setTimeout(‘pageload()‘,900);
$("#loadnum").html(loadi+‘%‘);
}
}

 

html部分:

<div id="up_pic" class="k xn c13 fl ra2 ma1" style="position:relative;color:red;text-align:center;background-color: deepskyblue;"> 上传图片<input type="file" id="file" style="width:100%;height:100%; cursor: pointer;outline: medium none; position: absolute; filter:alpha(opacity=0);-moz-opacity:0;opacity:0; left:0px;top: 0px;" onchange="showuphtml(0);"/></div>

假性进度效果

原文:http://www.cnblogs.com/songvli/p/4941881.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!