我使用的代码可以帮助我移动,调整大小和旋转网站上的图像。
我已经在移动设备上遇到了问题,它的旋转方向是反向的,并设法纠正了它,但是现在我又遇到了另一个问题。
当我的网站第一次加载图像时,其位置,旋转角度等...在PC上旋转+ n degres的图像将变为-n degres,而在移动设备上则相反。
这是代码:
e[a].Layer.prototype.rotateTo = function(e, a) {
if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) {
var r = this, s = this.rotation;
0 != r.index && (e *= 1, t([r.cont[0], r.handler[0]]).css({
"-moz-transform": "rotate(" + e + "deg)",
"-o-transform": "rotate(" + e + "deg)",
"-webkit-transform": "rotate(" + e + "deg)",
transform: "rotate(" + e + "deg)"
}), e = e < 0 ? Math.abs(e) : 360 - e, r.changeResizeCorner(2 * Math.round(e / 90)), r.rotation = e, a || r.$this.change(s !== r.rotation ? ["rotation"] : i))
} else {
var r = this, s = this.rotation;
0 != r.index && (e *= -1, t([r.cont[0], r.handler[0]]).css({
"-moz-transform": "rotate(" + e + "deg)",
"-o-transform": "rotate(" + e + "deg)",
"-webkit-transform": "rotate(" + e + "deg)",
transform: "rotate(" + e + "deg)"
}), e = e < 0 ? Math.abs(e) : 360 - e, r.changeResizeCorner(2 * Math.round(e / 90)), r.rotation = e, a || r.$this.change(s !== r.rotation ? ["rotation"] : i))
}
}
答案 0 :(得分:0)
检查e * =行。
e[a].Layer.prototype.rotateTo = function(e, a) {
if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) {
var r = this, s = this.rotation;
0 != r.index && (e *= 1, t([r.cont[0], r.handler[0]]).css({
"-moz-transform": "rotate(" + e + "deg)",
"-o-transform": "rotate(" + e + "deg)",
"-webkit-transform": "rotate(" + e + "deg)",
transform: "rotate(" + e + "deg)"
}), e = e < 0 ? Math.abs(e) : 360 - e, r.changeResizeCorner(2 * Math.round(e / 90)), r.rotation = e, a || r.$this.change(s !== r.rotation ? ["rotation"] : i))
} else {
var r = this, s = this.rotation;
0 != r.index && (e *= 1, t([r.cont[0], r.handler[0]]).css({
"-moz-transform": "rotate(" + e + "deg)",
"-o-transform": "rotate(" + e + "deg)",
"-webkit-transform": "rotate(" + e + "deg)",
transform: "rotate(" + e + "deg)"
}), e = e < 0 ? Math.abs(e) : 360 - e, r.changeResizeCorner(2 * Math.round(e / 90)), r.rotation = e, a || r.$this.change(s !== r.rotation ? ["rotation"] : i))
}
}