Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
132 views
in Technique[技术] by (71.8m points)

javascript - 基于触摸旋转对象(Rotating an object based on touch)

I am available to rotate an html object with JavaScript based on touch, but whenever I touch the screen again, it rotates to that value instead of rotating relative to its rotations

(我可以使用基于触摸的JavaScript旋转html对象,但是每当我再次触摸屏幕时,它都会旋转到该值,而不是相对于其旋转旋转)

var obj = document.getElementById("obj");
var x1;
function rotate(event) {
    x1 = event.touches[0].clientX + (window.innerWidth / 2);
    var objRx = 360 / (window.innerWidth / x1);
    obj.style.transform = "rotateY(" + objRx + "deg)";
}
  ask by WileyR translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...