簡體   English   中英

Phonegap / jQuery移動頁面過渡閃爍

[英]Phonegap/jQuery mobile page transition flickering

我是Phonegap / jQuery mobile的新手,頁面轉換問題期間遇到白屏。 我嘗試應用在Web上找到的許多解決方案(例如-webkit-backface-visibility:hidden; ),但仍未解決問題。

我也將defaultPageTransition設置為none (在jQuery mobile .js文件中)並且仍然沒有設置。

我不能關閉硬件加速,因為我的iDangerous滑動菜單需要它。 我所有的鏈接如下所示:

<a href='javascript:void(0)' class='news-main' onclick='someFunction()'>Some String</a>

當我單擊鏈接時,將調用someFunction()。 方法someFuction看起來像這樣:

function someFunction(){
    //setting some value that I need in next page
    window.sessionStorage.setItem("someValue",someValue);
    window.location="next-page.html";
}

一切正常,除了在頁面過渡期間出現白色閃爍。 並且僅在某些設備(例如Android 4+)上顯示。

有什么辦法解決這個問題? 或者也許我做錯了什么? 提前致謝!

您需要在調用Jquery移動js之前執行以下操作:

<script src="js/jquery-1.10.2.min.js" type="text/javascript"></script>
                <script type="text/javascript">
                $(document).bind("mobileinit", function()
                {
                   if (navigator.userAgent.indexOf("Android") != -1)
                   {
                     $.mobile.defaultPageTransition = 'none';
                     $.mobile.defaultDialogTransition = 'none';
                   }
                });
                </script>
                <script src="js/jquery.mobile-1.3.2.min.js" type="text/javascript"></script>

這就是足夠的參考

android:hardwareAccelerated="false"

打開清單並將其粘貼到應用程序標簽中。 因為您的設備硬件每次都會加速通話

嘗試如下

<a href='#' class='news-main' id='mylink'>Some String</a>

JS

$(document).on('pagecreate', function(){
  $('#mylink').bind('click',function(){
      someFunction()
  });
});

function someFunction(){
  window.sessionStorage.setItem("someValue",someValue);
  $.mobile.changePage("next-page.html");
}

為更高的Android目標構建時, android:hardwareAccelerated隱式設置為true,這會導致在使用jQuery Mobile過渡期間閃爍。

將其設置為android:hardwareAccelerated =“ false”將解決此問題。 (我也禁用了縮放和用戶可縮放性)

http://developer.android.com/guide/topics/graphics/hardware-accel.html

<script src="js/jquery-1.10.2.min.js" type="text/javascript"></script>
                <script type="text/javascript">
                $(document).bind("mobileinit", function()
                {
                   if (navigator.userAgent.indexOf("Android") != -1)
                   {
                     $.mobile.defaultPageTransition = 'none';
                     $.mobile.defaultDialogTransition = 'none';
                   }
                });
                </script>
                <script src="js/jquery.mobile-1.3.2.min.js" type="text/javascript"></script>

您可以將鏈接寫為

<a href='javascript:void(0)' class='news-main' onclick='someFunction()' data-transition="none" >Some String</a>

由於jquery mobile在頁面轉換中不是很平穩。因此,我們現在可以選擇關閉它們,直到發布具有正常頁面轉換的最新版本的jquery mobile。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM