We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
记不得的是多久之前,弄了个3d的骰子效果,不过无法通过鼠标拖拽来计算骰子的transform的rotateX,rotateY,于是一直搁置,最近在w3cfuns看到类似效果,查看源码,发现计算的算法,记录一下
var rY = 0, rX = 0, d1, d2; document.onmousedown = function(e){ var X = e.clientX; var Y = e.clientY; this.onmousemove = function(e){ var x = e.clientX, y = e.clientY; d1 = x-X; d2 = y-Y; //下面的0.2和0.07怎么来得? rY += d1 * 0.2; rX -= d2 * 0.07; oCube.style.transform = 'translateZ(-150px) rotateX('+rX+'deg) rotateY('+rY+'deg)'; X = x; Y = y; e.preventDefault(); return false; }; this.onmouseup = function(){ this.onmousemove = null; }; };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
记不得的是多久之前,弄了个3d的骰子效果,不过无法通过鼠标拖拽来计算骰子的transform的rotateX,rotateY,于是一直搁置,最近在w3cfuns看到类似效果,查看源码,发现计算的算法,记录一下
The text was updated successfully, but these errors were encountered: