官網地址:http://www.hatchpet.com/ 視頻需翻牆。
<code class="text">var scale = 1;
var baseHeight = 544 * scale;
var baseWidth = 602 * scale;
var eachFrame = 15;
var canvas = $('<canvas id="canvas"/>').css({
'position': 'fixed',
'zIndex': 9999,
'bottom': '0',
'overflow': 'hidden',
}).attr({
'width': baseWidth,
'height': baseHeight,
});
$('body').append(canvas);
var frameCnt = 0;
var context = canvas[0].getContext('2d');
function animate(isReset) {
if (isReset) {
frameCnt = 0;
};
// clear
context.clearRect(0, 0, baseWidth, baseHeight);
// draw stuff
context.drawImage(imageObjs[parseInt(frameCnt / eachFrame)], (frameCnt % eachFrame) * baseWidth, 0, baseWidth, baseHeight, 0, 0, baseWidth, baseHeight);
frameCnt++;
// request new frame
if (frameCnt < eachFrame * 2) {
setTimeout(animate, 1000 / 8);
} else {
animate(true);
}
}
var pic = [
'http://p1.zhimg.com/8c/fb/8cfbc0eb11019584c7ee0dccd4c8bf66_r.jpg',
'http://p1.zhimg.com/4f/3d/4f3db206b0fd094ef2fc00ece876ad30_r.jpg'
];
function preLoadImages(imgSrcList, callback) {
var imageObjs = [];
var len = imgSrcList.length;
var callbackAfter = len;
var preloadInterval = window.setInterval(function() {
if (callbackAfter === 0) {
window.clearInterval(preloadInterval);
callback();
}
}, 100);
for (var i = 0; i < len; i++) {
imageObjs[i] = new Image();
imageObjs[i].onload = function() {
callbackAfter--;
};
imageObjs[i].src = imgSrcList[i];
};
return imageObjs;
}
var imageObjs = preLoadImages(pic, function() {
animate(true);
});
</code>
在密密麻麻的压缩过的 js 源文件里搜了一下 licksprite ,还真发现了踪影:var licksprite;var showingSprite=false;var playState;var playerReady=false;var shouldStart=false;var spriteTime=50.08;…我对 js 只是非常一知半解,不过那个 spriteTime = 50.08 让人猜想,应该是检测在视频播放50.08秒后,触发网页上的 CSS sprite 动画。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号