Animating a DIV with JavaScript renders artifacts on Chrome

前端 未结 3 1455
逝去的感伤
逝去的感伤 2021-02-01 07:52

As an experiment, I am trying to replicate the Sprite functionality of AS3 in JavaScript without using the canvas object. I thought that using absolutely positioned divs and man

3条回答
  •  别跟我提以往
    2021-02-01 08:30

    It has something to do with subpixel positioning. If you round off to the nearest pixel you won't see those rendering errors:

    thisRef.block.style.left = Math.round((x + (mouseX - ox - x) * .125)) + "px";
    thisRef.block.style.top = Math.round((y + (mouseY - oy - y) * .125)) + "px";
    

提交回复
热议问题