分别在安卓、苹果上测试,疯狂点击屏幕,苹果很好,但是安卓停顿的很厉害。有什么方法解决么?
function Ball () { var r = Math.floor(Math.random() * 255); var g = Math.floor(Math.random() * 255); var b = Math.floor(Math.random() * 255); this.id = Date.now(); var ballDiv = '<div id="' + this.id + '" class="ball" style="position: absolute; top: 1rem; left: 9rem; width: 2rem; height: 2rem; background-color: rgb(' + r + ',' + g + ',' + b + ');"></div>' $('body').append(ballDiv); this.move(); } Ball.prototype.move = function () { setInterval(function () { var $dom = $('#' + this.id); var t = $dom.offset().top $dom.css({ transform: 'translateY(' + (t + .5) + 'px)' }) }.bind(this), 20); }; setInterval(function () { new Ball(); }, 2000)
南风蛮
qq_临摹不凡_0