window.resize()函数上的move()元素在Android上不起作用

move() element on window.resize() function not working on Android

本文关键字:Android 不起作用 元素 move 函数 window resize      更新时间:2023-09-26

这是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?

我很确定scrollLeft不工作在android上的某些原因。在iOS上运行得很好,但我却无法在android上运行。给它一个测试,看看你是否真的为它获得了一个值。

编辑:不仅是scrollLeft()函数,而且任何与水平滚动有关的东西似乎都无法在android中工作。

我使用的一个变通方法是使用css属性来实现左右移动:

-webkit-transform-webkit-transition-property-webkit-transition-timing-function-webkit-transition-duration

然而,这可能不适合你,因为你真的只是试图获得值,而不是实际移动的东西