Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1267068

    alex5252
    Participant

    I can not succesfully bind the swipe event to any element in the DOM on this site
    http://marckdesignconcepts.com/Lander/

    I took the code from this example (that I tested and does work)
    http://jsfiddle.net/qtfathho/

    $(document).ready(function(){
    // Previous/next slide on swipe
    $(document).on(‘swipeleft’, ‘.bg, header’,function(e){
    console.log(“swipe left”);
    });
    $(document).on(‘swiperight’, ‘.bg, header’,function(e){
    console.log(“swipe right”);
    });
    });

    I put this code into the page cornerstone JS, and I only changed the element the event is delegated to.

    jQuery(document).ready(function($){
    // Previous/next slide on swipe
    $(document).on(‘swipeleft’, ‘#cs-content’,function(e){
    console.log(“swipe left”);
    });
    $(document).on(‘swiperight’, ‘#cs-content’,function(e){
    console.log(“swipe right”);
    });
    });

    I have tried this on numerous elements throughout the DOM, none of which were dynamically added (though that shouldn’t have caused an issue anyway since im delegating the event.)

    I even checked to make sure the mobile Jquery file was enqueued and it is.
    I also checked through inspect element and the element indeed does have the event listener bound to it.

    I also checked to make sure the elements weren’t covered with a parent or child thus causing the event to fire unintentionally on the wrong element but this too was not the case.

    Therefore I have working code, successfully bound to the element, and event is triggered (swiping on that element and not another elemnt) and yet the function doesn’t execute.

    What is the issue?

    #1267069

    alex5252
    Participant
    This reply has been marked as private.
    #1267125

    Rupok
    Member

    Hi there,

    Unfortunately we can’t help much on your custom code. If you have any question regarding X or Cornerstone, let us know. As mentioned on our sidebar, “Support covers getting setup, theme features, and bug fixes. Regretfully we cannot provide support for 3rd party plugins or scripts.”

    Thanks for understanding.

    #1267203

    alex5252
    Participant

    Can you at least confirm that the swipe/swiperight/swipeleft events are or are not compatible or have .preventDefault() with X-Theme?

    #1267718

    Rupok
    Member

    Hi there,

    I don’t think there is .preventDefault() for this. However you can try adding .preventDefault() before your function to prevent any previous function.

    Thanks!