<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title></title>
<script type="text/javascript" src="/js/lib.min.js"></script>
<style type="text/css">
body{margin: 0;}
</style>
</head>
<body>
<button id="btn1" style="width: 200px; height: 100px;">隐藏</button>
<button id="btn2" style="width: 200px; height: 100px;">显示</button>
<div id="box" style="display none;">
<canvas id="canvas"></canvas>
</div>
</body>
<script type="text/javascript">
$(function() {
var _canvas = document.getElementById("canvas");
_canvas.width = $(document).width();
_canvas.height = $(document).height() - 150;
_stage = new createjs.Stage(_canvas);
var ss = new createjs.SpriteSheet({
images: ["/app/resource/image/trick/animation/cow_basketball/ploughR.png", "/app/resource/image/trick/animation/cow_basketball/ploughL.png"],
frames: {regX: 0, regY: 0, width: 374, height: 200, count: 8},
animations: {right: [0, 3], left: [4, 7]}
});
var bitmap = new createjs.BitmapAnimation(ss);
bitmap.x = 0;
bitmap.y = 0;
bitmap.scaleX = bitmap.scaleY = 1;
ss.getAnimation("right").next = "right";
ss.getAnimation("left").next = "left";
bitmap.gotoAndPlay("right");
_stage.addChild(bitmap);
createjs.Ticker.addEventListener("tick", _tick);
createjs.Ticker.setFPS(10);
var right = true;
function _tick() {
_stage.update();
if(!!right) {
bitmap.x = bitmap.x + 10;
} else {
bitmap.x = bitmap.x - 10;
}
if(bitmap.x > $(document).width()) {
right = false;
bitmap.gotoAndPlay("left");
}
if(bitmap.x < -bitmap.spriteSheet._frameWidth) {
right = true;
bitmap.gotoAndPlay("right");
}
};
$("#btn1").on("click", function() {
$("#box").hide();
});
$("#btn2").on("click", function() {
$("#box").show();
});
});
</script>
</html>
在这种情况下使用android三星手机有一些问题如下: 1.单击btn1隐藏div 2.然后单击btn2显示div(通常应该是动态图片)但此时页面有静态图片留在那里更多的
所以,我的问题是这个错误是如何出现的以及如何避免这个错误?