2013-05-03 51 views
1

我正在做html5-css-Jsmobile的phonegap項目...我正在使用多頁面模板... 我試圖用Iscroll來實現一些文本視圖的滾動......當我在FF上測試它只在我刷新頁面的時候才起作用...第一次加載頁面時它不起作用...在IO設備上它不起作用...滾動反彈到頂部, '向下滾動...我嘗試了一些不同的解決方案在網上發現...我試圖添加CSS高度#scroller> #wrapper ...試圖使用iscroll-lite ...IScroll反彈

在一些我有多個滾動頁...我發現唯一的解決方案是添加var myScroll2,var myScroll3等...

幫我;)

我的代碼:

<script type="text/javascript"> 

     var myScroll; 
     function loaded() { 
      myScroll = new iScroll('wrapper'); 

     } 

     document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false); 


     document.addEventListener('DOMContentLoaded', function() { setTimeout(loaded, 200); }, false); 


     </script> 

HTML DIV DATA-ROLE頁面滾動(我有一些人與滾動類似頁)

<div data-role="page" id="missione_archeologica" class="pag_video" data-iscroll="enable"> 
     <div data-role="content" style="top:0px;"> 

      <iframe width="100%" height="auto" src="http://www.youtube.com/embed/H-uLyp0z3Dg?rel=0;3&amp;autohide=1&amp;showinfo=0" frameborder="0" allowfullscreen style="color:transparent; height:182px; position:absolute;"></iframe> 
      <script type="text/javascript"> 
       if(navigator.onLine!==true) 
       document.getElementsByTagName('iframe')[0].outerHTML='<img src="images/menu/no_conn.png" style="width:100%; height:182px; position:absolute;">'; 
       </script> 

      <div class="titVideo"><img src="images/cultura/menu/missione.png" /></div> 
      <div id="wrapper"> 
       <div id="scroller"> 
        <p>Nel 1877 l'esploratore e geografo Renzo Manzoni, nipote del celebre scrittore di Fermo e Lucia, si reca nello Yemen dove soggiorna tre anni, in particolare a San'a, e scrive El Yèmen. Tre anni nell'Arabia Felice, pubblicato nel 1884. Manzoni racconta le sue impressioni di viaggio, con precise descrizioni degli ambienti, corredati da disegni e fotografie..... 
        </p> 
       </div></div> 


      <div data-role="footer" data-position="fixed" id="footer"> 
       <a href="#menu" id="HomeL" data-role="button" data-transition="fade"></a> 
       <a href="#cultura_menu" id="p_cultura" class="p_tab" data-role="button" data-transition="fade"></a> 
      </div> 

     </div> 
    </div> 
    </div> 
    <!--********* MISSIONE ARCHEOLOGICA *************--> 

CSS

#wrapper { 
position:absolute; z-index:1; 
top:221px; bottom:48px; left:0; 
width:100%; 
overflow:auto; 
height:206px; 
color:#FFF; 
text-shadow:none; 
font-family:"Interstate-Regular"; 
font-size: 13px; 
} 



#scroller { 
position:absolute; z-index:1; 
-webkit-tap-highlight-color:rgba(0,0,0,0); 
width:100%; 
padding:0; 
} 

#scroller p { 
padding:0px 12px 0px 12px; 

} 

回答

4

試初始化iScroll的超時時間如此

setTimeout(function() { 
     myScroll = new iScroll('wrapper'); 
    }, 100); 

這裏說 - http://cubiq.org/iscroll-4在onload部分

+0

謝謝!!! ...它的工作原理;) – Loralon 2013-05-04 00:07:05