问题描述
我的touchmove事件有问题。使用以下脚本,我将根据光标影响.Image类的转换属性。我想对触摸设备使用相同的效果。我已经尝试过用mousemove代替touchemove。 Twisty对其进行了很好的描述。但是,我无法正常工作。你有小费吗?
以下是在台式机上效果最好的脚本:
$(function(){
var bild = $(".bild");
bild.on('mousemove',function (e) {
var x = e.clientX - $(this).offset().left + $(window).scrollLeft();
var y = e.clientY - $(this).offset().top + $(window).scrollTop();
var rY = map(x,$(this).width(),-6,6);
var rX = map(y,$(this).height(),6);
$(this).children(".image").css("transform","rotateY(" + rY + "deg)" + " " + "rotateX(" + -rX + "deg)");
});
bild.on('mouseenter',function () {
$(this).children(".image").css({
transition: "all " + 0.02 + "s" + " linear",});
});
function map(x,in_min,in_max,out_min,out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
});
提前谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)