1

I have been trying to merge jquery mobile and iscroll5 for my project where I need pull to refresh function, smooth facebook like scrolling and loading content on scroll end. I have found one script which is working perfectly without jquery mobile, but when I use jquery mobile and try to scroll it detects my scrolling like hovering and when my finger is on the screen it is not smooth scrolling, and as I release it start to be smooth again.

I have been reading all articles these few last days and I couldnt fix it. I am using whis script http://pnc.co.il/dev/iscroll-5-pull-to-refresh-and-infinite-demo.html

Jquery Mobile version is 1.4.5. I am using it for cordoba latest versin project on android device.

The code is all from link I have provided, only change is that I have included jquery mobile javascript, css and themes folder.

I have changed this code

else if (refresh && next_page) {
                // Loading the next-page content and refreshing
                    $(function() {
                    inc += 10;
                    $.ajax({
                        dataType: "json",
                        url: "http://domain/json.php?l="+inc,  
                        type: "get",
                        success: function(data) {
                        console.log(data);
                            var temp    = '';
                            var i       = 0;
                            $.each(data, function(key, val) {
                                temp += '<li style="display:none" id="'+val.id+'"><a href="' + val.link + '" data-transition="slide" ><div class="imgLiquidFill imgLiquid" style="width:80px; height:60px;">' + val.slika + '</div><h2>' + val.naslov +'</h2><p><b>' + val.izvor + '</b>: ' + val.datum + '</p><p>' + val.tekst + '</p></a><div class="clear"></div></li>';

                                ++i;
                            });
                            $.mobile.loading( 'hide');
                            $('#wrapper > #scroller > ul').append(temp).listview('refresh');  
                            $(".imgLiquidFill").imgLiquid({fill:true}); 
                            $('li:hidden').show();              
                        }
                    }); 
                }); 

I am getting updated code on scroll, but my problem is that I cant scroll smooth

I think it would be best if I could lock clicking while scrolling, so My initial tap on screen would not be treated as click if it is start of scrolling.

css

    * {
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
    }

    html {
        -ms-touch-action: none;
    }

    body,ul,li {
        padding: 0;
        margin: 0;
        border: 0;
    }

    body {
        font-size: 12px;
        font-family: ubuntu, helvetica, arial;
        overflow: hidden; /* this is important to prevent the whole page to bounce */
    }

    #wrapper {
        position: absolute;
        z-index: 100;
        top: 45px;
        bottom: 48px;
        left:9999px; /* Not a must - can be 0 - but it makes the appearance of the content a bit nicer */
        width: 100%;
        background: #ccc;
        overflow: hidden;
    }

    #scroller {
        position: absolute;
        z-index: 100;
        -webkit-tap-highlight-color: rgba(0,0,0,0);
        width: 100%;
        -webkit-transform: translateZ(0);
        -moz-transform: translateZ(0);
        -ms-transform: translateZ(0);
        -o-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-text-size-adjust: none;
        -moz-text-size-adjust: none;
        -ms-text-size-adjust: none;
        -o-text-size-adjust: none;
        text-size-adjust: none;
    }

    #scroller ul {
        list-style: none;
        padding: 0;
        margin: 0;
        width: 100%;
        text-align: left;
        -webkit-transform: translate3d(0px, 0px, 0px);
    }

    #scroller li {
        padding: 0 10px;
        height: 80px;
        line-height: 80px;
        border-bottom: 1px solid #ccc;
        border-top: 1px solid #fff;
        background-color: #fafafa;
        font-size: 14px;
    }

scroller settings

myScroll = new IScroll('#wrapper', {
                probeType:1, 
                tap:true, 
                click:false, 
                preventDefaultException:{tagName:/.*/}, 
                mouseWheel:true, 
                scrollbars:true, 
                fadeScrollbars:true, 
                interactiveScrollbars:false, 
                keyBindings:false,
                deceleration:0.0002,
                startY:(parseInt(offset)*(-1))
            });
emir
  • 1,336
  • 1
  • 14
  • 33
  • some details please. Android Version, The Device(s) brand you are experiencing this problem, the JQM version you are using and the mobile browser(s) brand you are using. Some code will be helpful too. All these factors will help will identifying the issue. – Tasos Jan 06 '15 at 17:26
  • Can you post you scroller settings too. make sure you have (,useTransform: true ,useTransition: true). that should speed up the scroller in Webview for cordova. also check crosswalk as you can forgo using the crappy webview and use a supper fast chromium browser like google chrome for mobile. https://crosswalk-project.org/ – Tasos Jan 06 '15 at 19:21
  • forgot to mention. there is a css setting (-webkit-transform: translate3d(0px, 0px, 0px);) that can go to the (scroller ul) which forces the list to go into hardware acceleration mode. Frankly i'm not sure if this will help because its going to boil down to the Webview performance. Try the settings i mentioned above for the scroller first and let me know – Tasos Jan 06 '15 at 19:34
  • i have updated information, and added useTransform: true ,useTransition: true in my code now. I think it is better, but still not so smooth like without jquery mobile. When I tap screen and start scrolling, the item that has been pressed is changing state as I am clicking on it. – emir Jan 06 '15 at 19:49
  • Im glad i fixed your problem. i see you didn't have those options, well definitely need them for performance. When you say "still not so smooth like without jquery mobile" is that also when using cordova in a webview.?? --- ehh yes the items state changes if you hover too much on them but you can check here to disable that --- http://stackoverflow.com/questions/22926836/jquery-mobile-1-4-how-to-disable-hover-effect-on-mobile-devices – Tasos Jan 06 '15 at 19:53
  • I have tried in cordova example I have provided in link, and it is working smooth as native app. When I combine that code with jquery mobile the smootness is no longer there. The code you have told me to insert in iscroll has fixed problem with scrolling, but still when I start scrolling the item i press and move finger changes state as I have clicked. I dont need it to change state if I am scrolling, only when I am clicking. Could I fix it too? I have tried some of that code from stackoverflow but it looks like I am doing something wrong because it is not working. – emir Jan 06 '15 at 20:01
  • 1
    Turn Debug on for your Android app and plug the device in to a pc and use google chrome so you can inspect the elements on the fly and see whats happening. its easy -- -https://developer.chrome.com/devtools/docs/remote-debugging – Tasos Jan 06 '15 at 20:12
  • I didnt know about that thanks. I have added this code but the state of clicked list is changed while scrolling still $('#llista').on('click', 'li', function() { //alert("Works"); $(this).removeClass("ui-state-focus ui-state-hover"); }); – emir Jan 06 '15 at 20:30

0 Answers0