Fastclick.js jQuery Mobile Phonegap and Android

I can't make it all work together. I have phonegap / JQM working with fastclick.js perfectly on iOS. This is a dream. But for some reason, I still get a 300ms delay on Android. I entered some warnings and the code gets called. This is really puzzling. I am testing a maxx motor razor razor.

In my index.html file:

<!DOCTYPE html>
<html>
    <head>
        ...
        <script type='application/javascript' src='js/fastclick.js'></script>
    </head>
    <script>
    $(document).on("pagebeforechange", function (e, data) {
        FastClick.attach(document.body);
        alert('fastclick attached');
        var to_page = data.toPage[0].id;
        // skip showing #myPage if condition is true
        if (to_page == "index") {
            $.mobile.pageContainer.pagecontainer('change', 'event-list.html');
            e.preventDefault();
        }
    });

    </script>
    <body>
        <div id="index" data-role="page">
        This is the index page.
        </div>
    </body>
</html>

But that does not work. I also tried installing it as:

window.addEventListener('load', function() {
    new FastClick(document.body);
}, false);

Which ones work on iOS but don't seem to affect Android. Any suggestions?

edit: It seems that if I remove the jQuery libraries, it works fine. There must be a conflict somewhere. Any idea what this could be? I am using JQM 1.4.

edit: I also tried using vclick to no avail

$("#test-element").bind('vclick',function() {
    $.mobile.pageContainer.pagecontainer('change', 'description.html?lunch_pk=2133',{
        transition: "slide",
    });
});
...
<h1 id='test-element'> CLICK HERE FOR TEST </h1>

, 300 , , vclick , .

edit: ok, , - JQM-. console.log vclick, , . JQM, , , iOS Android? , , .

. , . Intel, , JQM, .

+4
6

vclick onclicks. jQuery Mobile vclick 300 . , .

$("#element").bind('vclick',function(event) {
   yourFunction(this.id);
   event.preventDefault();// this prevents the default click event
});
+1

jQueryMobile? :

setTimeout(function() {
    $link.removeClass( $.mobile.activeBtnClass );
    }, 300 );

, "" "-" .

.mobile.popup.handleLink = function( $link ) {
    ...
}
0

FastClick deviceready:

document.addEventListener('deviceready', function() {
    FastClick.attach(document.body);
}, false);
0

?

$("#test-element").off('tap').on('tap', function(event) {...do your stuff});

, .bind - /

, , , change revisit.

- pageinit, , , , .

, "" (. )

0

. , , JQM:

$('#button').unbind('touchstart click').bind('touchstart click', function(event) {
    $('#button').addClass('ui-btn-active');
    //doSomethingHere();
    setTimeout(function() {
        $('#button').removeClass('ui-btn-active');
    }, 300); //this 300ms is just the delay for styling the button
    event.preventDefault(); //if touchstart is supported, do not let the event propagate to the click handler.  Having this here avoids a double trigger.
});

touchstart, .

. , , . , , .

0

, JQM. CSS "fade" ( jquery.mobile.structure.css v1.4.2):

.fade.out {
  opacity: 0;
  -webkit-animation-duration: 125ms;
  -webkit-animation-name: fadeout;
  -moz-animation-duration: 125ms;
  -moz-animation-name: fadeout;
  animation-duration: 125ms;
  animation-name: fadeout;
}
.fade.in {
  opacity: 1;
  -webkit-animation-duration: 225ms;
  -webkit-animation-name: fadein;
  -moz-animation-duration: 225ms;
  -moz-animation-name: fadein;
  animation-duration: 225ms;
  animation-name: fadein;
}

JQM , , "" , , 225 , (125 ), .. 350 .

, {transition: 'none'} $.mobile.pageContainer.pagecontainer('change' $.mobile.defaultPageTransition = "none"; mobileinit, .

Phonegap JQM - (Android), , Android. , , - DOM. , setTimeout , - , DOM.

0

Source: https://habr.com/ru/post/1527637/


All Articles