Question

i'm doing phonegap project with html5-css-Jsmobile...i'm using a multipage template... i'm trying to use Iscroll to implement scroll for some text views...when i test it on FF it works only if i refresh the page...the first time i load the page it doesn't work...on iOs device it doesn't work...the scroll bounces to the top and doesn't scroll down...i tried some differents solutions finded on the web...i tried to add css hight to the #scroller>#wrapper...tried to use iscroll-lite...

in some page i have multiple scroll...the only solution i found is to add var myScroll2, var myScroll3 and so on...

Help me ;)

my code:

<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 PAGE with the scroll (i have some others similar pages with scroll)

    <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;

}
Was it helpful?

Solution

try initializing the iScroll in a timeout like so

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

as stated here - http://cubiq.org/iscroll-4 in the ONLOAD section

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top