【问题标题】:move() element on window.resize() function not working on Androidwindow.resize() 函数上的 move() 元素在 Android 上不起作用
【发布时间】:2011-09-30 10:17:45
【问题描述】:

这是 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 中无效?

【问题讨论】:

  • 构建一个简单而抽象的测试用例并在jQuery Bug-Tracker上提交一个错误。

标签: javascript jquery android resize scroll


【解决方案1】:

我很确定 scrollLeft 出于某种原因不能在 android 上运行。在 iOS 上运行良好,但我无法让它在 android 上运行。给它一个测试,看看你是否真的得到了它的价值。

编辑:不仅仅是函数 scrollLeft(),而且与水平滚动有关的任何事情似乎在 android 中都不起作用。

我用来让事物实际向左/向右移动的解决方法是 css 属性:

-webkit-transform -webkit-过渡属性 -webkit-transition-timing-function -webkit-transition-duration

但这可能对您不起作用,因为您实际上只是想获得价值而不是实际移动某些东西。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-16
    • 1970-01-01
    • 2018-10-01
    • 2018-08-09
    • 1970-01-01
    • 2011-07-05
    • 2013-07-29
    • 2018-09-22
    相关资源
    最近更新 更多