<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        HTML5超炫酷粒子效果的進度條圖文代碼詳細介紹

        來源:懂視網 責編:小采 時間:2020-11-27 15:12:11
        文檔

        HTML5超炫酷粒子效果的進度條圖文代碼詳細介紹

        HTML5超炫酷粒子效果的進度條圖文代碼詳細介紹:這是一款基于HTML5和JavaScript的進度條應用,這款進度條插件非常有特點,它在進度展示的時候呈現粒子的動畫效果,也就是說,進度條在滑動的同時,會產生一些小粒子掉落下來,效果非常酷。另外還有一個特點是隨著進度的變化,進度條的顏色也會變化。在線演示
        推薦度:
        導讀HTML5超炫酷粒子效果的進度條圖文代碼詳細介紹:這是一款基于HTML5和JavaScript的進度條應用,這款進度條插件非常有特點,它在進度展示的時候呈現粒子的動畫效果,也就是說,進度條在滑動的同時,會產生一些小粒子掉落下來,效果非常酷。另外還有一個特點是隨著進度的變化,進度條的顏色也會變化。在線演示

        這是一款基于HTML5和JavaScript的進度條應用,這款進度條插件非常有特點,它在進度展示的時候呈現粒子的動畫效果,也就是說,進度條在滑動的同時,會產生一些小粒子掉落下來,效果非常酷。另外還有一個特點是隨著進度的變化,進度條的顏色也會變化。

        JavaScript代碼

        /*========================================================*/ 
        /* Light Loader
        /*========================================================*/
        var lightLoader = function(c, cw, ch){
        
        	var _this = this;
        	this.c = c;
        	this.ctx = c.getContext('2d');
        	this.cw = cw;
        	this.ch = ch;	
        
        	this.loaded = 0;
        	this.loaderSpeed = .6;
        	this.loaderHeight = 10;
        	this.loaderWidth = 310;	
        	this.loader = {
        	x: (this.cw/2) - (this.loaderWidth/2),
        	y: (this.ch/2) - (this.loaderHeight/2)
        	};
        	this.particles = [];
        	this.particleLift = 180;
        	this.hueStart = 0
        	this.hueEnd = 120;
        	this.hue = 0;
        	this.gravity = .15;
        	this.particleRate = 4;	
        
        	/*========================================================*/	
        	/* Initialize
        	/*========================================================*/
        	this.init = function(){
        	this.loop();
        	};
        
        	/*========================================================*/	
        	/* Utility Functions
        	/*========================================================*/	
        	this.rand = function(rMi, rMa){return ~~((Math.random()*(rMa-rMi+1))+rMi);};
        	this.hitTest = function(x1, y1, w1, h1, x2, y2, w2, h2){return !(x1 + w1 < x2 || x2 + w2 < x1 || y1 + h1 < y2 || y2 + h2 < y1);};
        
        	/*========================================================*/	
        	/* Update Loader
        	/*========================================================*/
        	this.updateLoader = function(){
        	if(this.loaded < 100){
        	this.loaded += this.loaderSpeed;
        	} else {
        	this.loaded = 0;
        	}
        	};
        
        	/*========================================================*/	
        	/* Render Loader
        	/*========================================================*/
        	this.renderLoader = function(){
        	this.ctx.fillStyle = '#000';
        	this.ctx.fillRect(this.loader.x, this.loader.y, this.loaderWidth, this.loaderHeight);
        
        	this.hue = this.hueStart + (this.loaded/100)*(this.hueEnd - this.hueStart);
        
        	var newWidth = (this.loaded/100)*this.loaderWidth;
        	this.ctx.fillStyle = 'hsla('+this.hue+', 100%, 40%, 1)';
        	this.ctx.fillRect(this.loader.x, this.loader.y, newWidth, this.loaderHeight);
        
        	this.ctx.fillStyle = '#222';
        	this.ctx.fillRect(this.loader.x, this.loader.y, newWidth, this.loaderHeight/2);
        	};	
        
        	/*========================================================*/	
        	/* Particles
        	/*========================================================*/
        	this.Particle = function(){	
        	this.x = _this.loader.x + ((_this.loaded/100)*_this.loaderWidth) - _this.rand(0, 1);
        	this.y = _this.ch/2 + _this.rand(0,_this.loaderHeight)-_this.loaderHeight/2;
        	this.vx = (_this.rand(0,4)-2)/100;
        	this.vy = (_this.rand(0,_this.particleLift)-_this.particleLift*2)/100;
        	this.width = _this.rand(1,4)/2;
        	this.height = _this.rand(1,4)/2;
        	this.hue = _this.hue;
        	};
        
        	this.Particle.prototype.update = function(i){
        	this.vx += (_this.rand(0,6)-3)/100; 
        	this.vy += _this.gravity;
        	this.x += this.vx;
        	this.y += this.vy;
        
        	if(this.y > _this.ch){
        	_this.particles.splice(i, 1);
        	}	
        	};
        
        	this.Particle.prototype.render = function(){
        	_this.ctx.fillStyle = 'hsla('+this.hue+', 100%, '+_this.rand(50,70)+'%, '+_this.rand(20,100)/100+')';
        	_this.ctx.fillRect(this.x, this.y, this.width, this.height);
        	};
        
        	this.createParticles = function(){
        	var i = this.particleRate;
        	while(i--){
        	this.particles.push(new this.Particle());
        	};
        	};
        
        	this.updateParticles = function(){	
        	var i = this.particles.length;	
        	while(i--){
        	var p = this.particles[i];
        	p.update(i);	
        	};	
        	};
        
        	this.renderParticles = function(){
        	var i = this.particles.length;	
        	while(i--){
        	var p = this.particles[i];
        	p.render();	
        	};	
        	};
        
        	/*========================================================*/	
        	/* Clear Canvas
        	/*========================================================*/
        	this.clearCanvas = function(){
        	this.ctx.globalCompositeOperation = 'source-over';
        	this.ctx.clearRect(0,0,this.cw,this.ch);	
        	this.ctx.globalCompositeOperation = 'lighter';
        	};
        
        	/*========================================================*/	
        	/* Animation Loop
        	/*========================================================*/
        	this.loop = function(){
        	var loopIt = function(){
        	requestAnimationFrame(loopIt, _this.c);
        	_this.clearCanvas();
        
        	_this.createParticles();
        
        	_this.updateLoader();
        	_this.updateParticles();
        
        	_this.renderLoader();
        	_this.renderParticles();
        
        	};
        	loopIt();	
        	};
        
        };
        
        /*========================================================*/	
        /* Check Canvas Support
        /*========================================================*/
        var isCanvasSupported = function(){
        	var elem = document.createElement('canvas');
        	return !!(elem.getContext && elem.getContext('2d'));
        };
        
        /*========================================================*/	
        /* Setup requestAnimationFrame
        /*========================================================*/
        var setupRAF = function(){
        	var lastTime = 0;
        	var vendors = ['ms', 'moz', 'webkit', 'o'];
        	for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x){
        	window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
        	window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
        	};
        
        	if(!window.requestAnimationFrame){
        	window.requestAnimationFrame = function(callback, element){
        	var currTime = new Date().getTime();
        	var timeToCall = Math.max(0, 16 - (currTime - lastTime));
        	var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
        	lastTime = currTime + timeToCall;
        	return id;
        	};
        	};
        
        	if (!window.cancelAnimationFrame){
        	window.cancelAnimationFrame = function(id){
        	clearTimeout(id);
        	};
        	};
        };	
        
        /*========================================================*/	
        /* Define Canvas and Initialize
        /*========================================================*/
        if(isCanvasSupported){
         var c = document.createElement('canvas');
         c.width = 400;
         c.height = 100;	
         var cw = c.width;
         var ch = c.height;	
         document.body.appendChild(c);	
         var cl = new lightLoader(c, cw, ch);	
        
         setupRAF();
         cl.init();
        }

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        HTML5超炫酷粒子效果的進度條圖文代碼詳細介紹

        HTML5超炫酷粒子效果的進度條圖文代碼詳細介紹:這是一款基于HTML5和JavaScript的進度條應用,這款進度條插件非常有特點,它在進度展示的時候呈現粒子的動畫效果,也就是說,進度條在滑動的同時,會產生一些小粒子掉落下來,效果非常酷。另外還有一個特點是隨著進度的變化,進度條的顏色也會變化。在線演示
        推薦度:
        標簽: 特效 進度條 代碼
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 4444www免费看| 你是我的城池营垒免费看 | 78成人精品电影在线播放日韩精品电影一区亚洲 | 在线播放高清国语自产拍免费| 久久久久亚洲av无码专区喷水| 99在线免费视频| 亚洲av无码一区二区三区不卡| 日韩a级无码免费视频| 亚洲乱亚洲乱妇无码麻豆| 久草福利资源网站免费| 亚洲av日韩综合一区在线观看| 一级毛片免费毛片一级毛片免费 | 国产一卡2卡3卡4卡2021免费观看| 亚洲成人福利在线| 插B内射18免费视频| 久久精品国产亚洲AV未满十八| 国产免费131美女视频| 一区二区视频在线免费观看| 亚洲一区二区精品视频| 黄网站免费在线观看| 亚洲精品国产第1页| 成人毛片免费观看视频大全| 亚洲国产精品无码第一区二区三区 | 人妻免费久久久久久久了| 国产亚洲高清不卡在线观看| 中文字幕在线观看免费视频| 一本色道久久综合亚洲精品蜜桃冫 | 免费国产成人α片| 亚洲1234区乱码| 亚洲精品岛国片在线观看| 国产无遮挡无码视频免费软件| 亚洲综合国产精品| 免费视频淫片aa毛片| h视频在线观看免费| 亚洲色图视频在线观看| 国产最新凸凹视频免费| 一个人免费视频在线观看www| 久久亚洲春色中文字幕久久久| 日韩一品在线播放视频一品免费| 久久av免费天堂小草播放| 亚洲国产av美女网站|