【问题标题】:Tablet: on orientationchange the page jumps to start平板电脑:在orientationchange页面跳转开始
【发布时间】:2016-04-11 08:19:47
【问题描述】:

三星平板有问题,如果用户在页面底部并改变方向,它会再次跳转到页面开头。

我没有使用任何事件监听器,例如“orientationchange”等

在 Ipad 中,用户在改变方向时会停留在相同的位置。

任何帮助。

【问题讨论】:

  • 检查你的三星上的另一个浏览器,还有另一个安卓平板电脑,我认为这个行为应该是由三星浏览器触发的,而不是所有的安卓平板电脑

标签: javascript html tablet


【解决方案1】:

为了控制方向变化,你可以使用这样的东西:

let View = // object
{
    onTilt: function()
    {
        // get target scroll-height and do some stuff
    }
};


window.addEventListener
(
    "resize", function()
    {
        var x, y, d, a, t;

        x = window.innerWidth,
        y = window.innerHeight,
        d = Math.gcd(x,y);
        a = {x:(x / d), y:(y / d)};

        vSys.Size = // object
        {
            x:window.screen.availWidth,
            y:window.screen.availHeight
        };

        t = ((y > x) ? 'high' : 'wide');

        if ((vSys.tilt != t) ? true : false)
        { View.onTilt(t) }

        View.tilt = t;
    },
    false
);


Math.gcd = function(a,b)
{
    var t, m;

    if (b > a)
    {
        t = a;
        a = b;
        b = t
    }

    while (b != 0)
    {
        m = a%b;
        a = b;
        b = m;
    }

    return a;
};

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-18
    • 1970-01-01
    • 2012-08-31
    相关资源
    最近更新 更多