标签:ast nim targe can 服务 设置 动效 取消 html
1 /* requestAnimationFrame.js 2 * by zhangxinxu 2013-09-30 3 */ 4 (function() { 5 var lastTime = 0; 6 var vendors = [‘webkit‘, ‘moz‘]; 7 for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { 8 window.requestAnimationFrame = window[vendors[x] + ‘RequestAnimationFrame‘]; 9 window.cancelAnimationFrame = window[vendors[x] + ‘CancelAnimationFrame‘] || // name has changed in Webkit 10 window[vendors[x] + ‘CancelRequestAnimationFrame‘]; 11 } 12 13 if (!window.requestAnimationFrame) { 14 window.requestAnimationFrame = function(callback) { 15 var currTime = new Date().getTime(); 16 var timeToCall = Math.max(0, 16.7 - (currTime - lastTime)); 17 var id = window.setTimeout(function() { 18 callback(currTime + timeToCall); 19 }, timeToCall); 20 lastTime = currTime + timeToCall; 21 return id; 22 }; 23 } 24 if (!window.cancelAnimationFrame) { 25 window.cancelAnimationFrame = function(id) { 26 clearTimeout(id); 27 }; 28 } 29 }());
newImgObjs[i] = new Image(); newImgObjs[i].src = animationImgs[i]; newImgObjs[i].onload = function() { loadeds++; if (loadeds == newImgObjs.length) { self.barObj.completeWelcomePromise.resolve(); console.log(‘图片资源已经加载完成‘); } }; newImgObjs[i].onerror = function() { loadeds++; if (loadeds == newImgObjs.length) { self.barObj.completeWelcomePromise.resolve(); console.log(‘图片资源已经加载完成‘); } };
$audio[0].src = imgPath; $audio.on(‘canplaythrough‘, function() { loadeds++; if (loadeds == (newImgObjs.length + 1)) { self.barObj.completePromise.resolve(); console.log(‘音频资源已经加载完成‘); } }); $audio[0].onerror = function(e) { loadeds++; if (loadeds == (newImgObjs.length + 1)) { self.barObj.completePromise.resolve(); console.log(‘音频资源已经加载完成‘); } };
// 资源处理:预加载、监控加载完成、渲染 $.when(self.cmsInfoPromise, self.goodsInfoPromise, self.barObj.completeWelcomePromise) .done(function() { // 进度条动效 self.barAnimation(); self.handleResource(); self.renderStores(); });
动画性能优化-requestanimationframe、GPU等
标签:ast nim targe can 服务 设置 动效 取消 html
原文地址:http://www.cnblogs.com/hity-tt/p/6420749.html