window.resize() 函数上的 move() 元素在 Android 上不起作用
这是 move() 函数
function move(){
/*calculate*/
var size = { x: $(window).width(), y: $(window).height() };
var scroll = { x: $(window).scrollLeft(), y: $(window).scrollTop() };
var height = h!=null ? h : this.esqueleto.lightbox.outerHeight();
var width = w!=null ? w : this.esqueleto.lightbox.outerWidth();
var y = 0;
var x = 0;
//vertically center
x = scroll.x + ((size.x - width) / 2);
if (this.visible) {
y = scroll.y + (size.y - height) / 2;
} else if (this.options.emergefrom == "bottom") {
y = (scroll.y + size.y + 14);
} else {// top
y = (scroll.y - height) - 14;
}
/*Process*/
if (!this.animations.move) {
this.morph(this.esqueleto.move, {
'left' : x
}, 'move');
}
this.morph(this.esqueleto.move, {
'top' : y
}, 'move');
} else {
this.esqueleto.move.css({
'left' : x,
'top' : y
});
}
}
你知道为什么它可以在桌面(所有浏览器)、iphone 等中工作,但不能在 Android 中工作吗?
This is the move() function
function move(){
/*calculate*/
var size = { x: $(window).width(), y: $(window).height() };
var scroll = { x: $(window).scrollLeft(), y: $(window).scrollTop() };
var height = h!=null ? h : this.esqueleto.lightbox.outerHeight();
var width = w!=null ? w : this.esqueleto.lightbox.outerWidth();
var y = 0;
var x = 0;
//vertically center
x = scroll.x + ((size.x - width) / 2);
if (this.visible) {
y = scroll.y + (size.y - height) / 2;
} else if (this.options.emergefrom == "bottom") {
y = (scroll.y + size.y + 14);
} else {// top
y = (scroll.y - height) - 14;
}
/*Process*/
if (!this.animations.move) {
this.morph(this.esqueleto.move, {
'left' : x
}, 'move');
}
this.morph(this.esqueleto.move, {
'top' : y
}, 'move');
} else {
this.esqueleto.move.css({
'left' : x,
'top' : y
});
}
}
Any idea why is this working in desktop (all browsers), iphone, .. but not in Android?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很确定由于某种原因scrollLeft 不能在android 上工作。在 iOS 上运行得很好,但我永远无法让它在 Android 上运行。对其进行测试,看看您是否真正获得了回报。
编辑:不仅仅是函数scrollLeft(),而且与水平滚动有关的任何东西似乎在android中都不起作用。
我用来让东西实际向左/向右移动的解决方法是 css 属性:
-webkit-transform
-webkit-过渡属性
-webkit-转换计时函数
-webkit-transition-duration
但是,这可能对您不起作用,因为您实际上只是想获取值而不是实际移动某些东西。
I'm pretty certain scrollLeft doesn't work on android for some reason. Works beautifully on iOS, but I could never get it to work on android. Give it a test and see if you are actually getting a value back for it.
Edit: not just the function scrollLeft(), but really anything to do with horizontal scrolling doesn't seem to work in android.
A workaround I'm using to get things to actually move left/right is are the css properties:
-webkit-transform
-webkit-transition-property
-webkit-transition-timing-function
-webkit-transition-duration
However that might not work for you since you're really just trying to get the value rather than actually move something.