window.scrollTo在IOS的phonegap不工作 [英] window.scrollTo doesn't work in phonegap for IOS

查看:1027
本文介绍了window.scrollTo在IOS的phonegap不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在呼叫:

  window.scrollTo(0,this.stateModel.get(scrollY)); 



在视图的渲染函数中的phonegap。



有没有任何原因scrollTo不能在IOS上工作?

解决方案

我也有这个问题。作为解决方法,我只是在所需的位置创建一个锚点元素,然后调用隐藏锚点链接上的点击事件。

 < a class =anchorhref =#desiredLocationstyle =display:none;& / a> 
< a id =desiredLocation>< / a>

jQuery代码...

  $(。anchor)。click(); 

不是最优雅的解决方案,但它提供相同的行为。


I am calling:

window.scrollTo(0,this.stateModel.get("scrollY"));

in phonegap in a view's render function.

This code works on the android emulator, but not on the iPhone 6.0 emulator.

Is there any reason scrollTo wouldn't work on IOS?

解决方案

I had issues with this as well. As a workaround, I simply created an anchor element in the desired position and then invoked a click event on a hidden anchor link.

<a class="anchor" href="#desiredLocation" style="display: none;"></a>
<a id="desiredLocation"></a>

jQuery code...

$(".anchor").click();

Not the most elegant solution, but it provides the same behavior.

这篇关于window.scrollTo在IOS的phonegap不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆