1 回答

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超4個贊
用window.getComputedStyle(elem).getPropertyValue("transform")
可以得到實(shí)際的transform值
Demo如下:
<html>
<style>
#block {
position: absolute;
width: 100px;
height: 100px;
transition: all 5s ease;
background-color: blue;
}
.move {
transform: translate(200px, 400px);
}
</style>
<div id=block></div>
<script type="text/javascript">
var blk = document.getElementById("block"), tid;
blk.onclick = function() {
blk.classList.add("move")
tid = setInterval(function() {
console.log(window.getComputedStyle(blk).getPropertyValue("transform"))
}, 10)
setTimeout(function() {
clearInterval(tid)
}, 5000)
}
</script>
</html>
添加回答
舉報