设置transform属性,translate3d可以开启硬件的3d加速,提示性能
let left =1,top=50;
img[i].style.transform = "translate3d("+left+"px,"+top+"px,"+"0)";
获取元素的transform属性
let translates = document.defaultView.getComputedStyle(img,null).transform;
解析X轴数值
let translateX = parseFloat(translates.substring(6).split(‘,‘)[4]);
解析Y轴数值
let tanslateY = parseFloat(translates.substring(6).split(‘,‘)[5]);
原文:https://www.cnblogs.com/webwangjie/p/11338670.html