使用 JQuery 和 Scrollto 插件自动滚动时 iPad 闪烁

发布于 2024-09-30 19:31:05 字数 443 浏览 7 评论 0原文

对于我正在开发的页面,我在 iOS 平台上遇到了一些奇怪的问题。 是有问题的页面。单击任何案例研究图像时,页面将首先取消隐藏所需的案例研究,然后滚动到它。

这适用于 Windows 和 Mac 上的所有桌面浏览器,但在 iPhone 和 iPad 上,向下滚动时会出现可怕的闪烁。

不太确定如何调试或解决此问题。

任何想法都会有很大帮助!

提前致谢, Shadi

更新 1

可以在此处找到最新页面。仍然没有找到解决办法 - 如果有人有任何想法那就太棒了!

I am having a bit of a weird problem with iOS platform for a page i am developing. This is the page in question. When clicking any of the case study images, the page will first unhide the required case study then scroll to it.

This works on all desktop browsers on Windows and Mac, but on the iPhone and iPad you get a horrible flicker as it scrolls down.

Not quite sure how to debug or fix this issue.

Any ideas would be of great help!

Thanks in advance,
Shadi

UPDATE 1

The latest page can be found here. Still haven't found a fix - if anyone has any idea it would be amazing!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

北笙凉宸 2024-10-07 19:31:05

如果您只需要垂直滚动,则可以使用 {'axis':'y'} 作为scrollTo 方法的设置。

$.scrollTo(*selector*, *time*, {'axis':'y'});

If you need vertical scroll only, you could use {'axis':'y'} as settings to scrollTo method.

$.scrollTo(*selector*, *time*, {'axis':'y'});
傻比既视感 2024-10-07 19:31:05

你有没有尝试过这个:

$('a[href=#target]').
    click(function(){
        var target = $('a[name=target]');
        if (target.length)
        {
            var top = target.offset().top;
            $('html,body').animate({scrollTop: top}, 1000);
            return false;
        }
    });

Have you tried this:

$('a[href=#target]').
    click(function(){
        var target = $('a[name=target]');
        if (target.length)
        {
            var top = target.offset().top;
            $('html,body').animate({scrollTop: top}, 1000);
            return false;
        }
    });
诺曦 2024-10-07 19:31:05

如果你只是垂直滚动页面,你可以用这个简单的行替换整个 jQuery scrollTo 插件:

$('html,body').animate({scrollTop: $("#scrollingTo").offset().top}, 1000, 'easeOutCubic');

就我个人而言,我做了这样的事情

$('html,body').animate({scrollTop: $("#step-1").offset().top-15}, 1000, 'easeOutCubic',function(){
  //do stuff
});

我发现,如果我尝试在滚动时执行其他 js 工作,它会使浏览器嘎吱作响并且动画并不顺利。但如果您使用回调,它会先滚动,然后执行您需要的操作。

我在 .top 的末尾放置了 -15,因为我想显示我正在滚动的 div 的顶部边缘,只是出于美观目的。 1000 是动画的持续时间(以毫秒为单位)。

感谢海报、动画、提示。

If you're just scrolling the page vertically you can replace the entire jQuery scrollTo plugin with this simple line:

$('html,body').animate({scrollTop: $("#scrollingTo").offset().top}, 1000, 'easeOutCubic');

Personally I do something like this

$('html,body').animate({scrollTop: $("#step-1").offset().top-15}, 1000, 'easeOutCubic',function(){
  //do stuff
});

I found that if I try to do other js work while it's scrolling it makes the browser crunch and the animation isn't smooth. But if you use the callback it'll scroll first, then do what you need.

I put a -15 at the end of .top because I wanted to show the top edge of the div I was scrolling do, simply for aesthetic purposes. 1000 is the duration in milliseconds of the animation.

Credit goes to the poster, animate, for the tip off.

蓝咒 2024-10-07 19:31:05

定义 {'axis':'y'} 已经使它正确了!它帮助我解决了向上/向下滑动的闪烁问题。

Defining {'axis':'y'} has made it right! It helped me with slideUp/Down flickering.

假情假意假温柔 2024-10-07 19:31:05

我不确定这是否适用于 jquery 动画。但以下似乎会影响 CSS 动画。

http://css-infos.net/property/-webkit-backface-visibility

语法

-webkit-backface-visibility: visibility;

参数

可见性
确定变换后的元素的背面是否可见。默认值是可见的。

编辑

尝试将其应用到每个元素,看看会发生什么。

*{
 -webkit-backface-visibility: visible;
}

并尝试

*{
-webkit-backface-visibility: hidden;
}

这只是一个猜测真的......

I'm not sure if this applies to jquery animations. But the following seems to affect CSS animations.

http://css-infos.net/property/-webkit-backface-visibility

Syntax

-webkit-backface-visibility: visibility;

Parameters

visibility
Determines whether or not the back face of a transformed element is visible. The default value is visible.

edit

Try applying it to every element and see what happens.

*{
 -webkit-backface-visibility: visible;
}

and try

*{
-webkit-backface-visibility: hidden;
}

It's just a guess really...

霓裳挽歌倾城醉 2024-10-07 19:31:05

我还将确认 Tund Do 的方法完美无缺。如果您需要同一件事的“左/右”变体(就像我所做的那样),那就是:

$('.pg6').click(function(){
    var target = $('#page6');
    if (target.length)
    {
        var left = target.offset().left;
        $('html,body').animate({scrollLeft: left}, 1000);
        return false;
    }
});

我猜您可以将两者结合起来,抓住顶部位置并将动画链接为“左/右/上/下” ”动画也。

I will also confirm Tund Do's method works flawlessly. If you need a "left/right" variation of the same thing (as I did) here it is:

$('.pg6').click(function(){
    var target = $('#page6');
    if (target.length)
    {
        var left = target.offset().left;
        $('html,body').animate({scrollLeft: left}, 1000);
        return false;
    }
});

I would guess you could combine the two, grab the top position and chain the animates for a "left/right/up/down" animation also.

捎一片雪花 2024-10-07 19:31:05

我也有同样的问题。

问题是 ScrollTo 插件。不使用scrollto.js,只需使用带有scrollTop 的.animate。 ipad/iphone 不再闪烁。

这是没有闪烁的 http://www.sneakermatic.com

I had the same problem.

The problem is the ScrollTo plugin. Instead of using scrollto.js just use .animate with scrollTop. No more flickering in ipad/iphone.

Here it is with no flickering http://www.sneakermatic.com

倾城花音 2024-10-07 19:31:05

您应该在选项对象中包含 {axis: 'y'}。还要确保您没有启用中断选项。您可以使用 {interrupt: false} 对此进行测试。

You should include {axis: 'y'} in your options object. Also be sure that you have not enabled interrupt option. You can test this with {interrupt: false}.

指尖上得阳光 2024-10-07 19:31:05

您需要将 e.preventDefault(); 添加到每个 .click() 调用中。这可以防止浏览器的默认操作,即停留在同一位置。希望这有帮助!
IE

$("#quicksand li, .client-list li").click(function (e) {
  e.preventDefault();
  ...
});

You need to add e.preventDefault(); to each .click() call. This prevents the browser's default action, which is to stay in the same place. Hope this helps!
i.e.

$("#quicksand li, .client-list li").click(function (e) {
  e.preventDefault();
  ...
});
只想待在家 2024-10-07 19:31:05

我在 iPhone 上也遇到了同样的闪烁问题——即使使用了 PreventDefault 和 return false 取消默认点击事件的选项。看起来在设备上它会在滚动之前尝试返回到页面顶部。如果你同时有scrollTop 和scrollLeft 动画,那确实会出现问题。这是 jQuery 的问题。我见过使用 mootools 的滚动方法,但没有这个问题。请参阅此页面:http://melissahie.com/

I'm having the same flickering on iPhone -- even with the preventDefault and return false options of canceling the default click event. It appears that on the device it tries to go back to the top of the page before scrolling. If you have both a scrollTop and scrollLeft animation going on it really gets buggy. It's jQuery's issue.. I've seen a scrolling method with mootools that doesn't have this issue. See this page: http://melissahie.com/

离不开的别离 2024-10-07 19:31:05

感谢 nicole 提供了 mootools 的示例。
当尝试在scrollTop 和scrollLeft 上执行动画时,这确实似乎是一个jQuery 问题。

配合 mootools:

var scroll = new Fx.Scroll(window, {duration: 1000, wait: false, transition: Fx.Transitions.quadInOut});
scroll.start(y, x);

在 iOS5 上完美运行!

Thanks nicole for giving the example with mootools.
It really seems to be a jQuery issue when trying to do a animation on BOTH scrollTop and scrollLeft.

With mootools:

var scroll = new Fx.Scroll(window, {duration: 1000, wait: false, transition: Fx.Transitions.quadInOut});
scroll.start(y, x);

it works flawlessly on iOS5!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文