Tagged: x
-
AuthorPosts
-
November 22, 2016 at 11:21 am #1267068
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?
November 22, 2016 at 11:22 am #1267069This reply has been marked as private.November 22, 2016 at 12:14 pm #1267125Hi 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.
November 22, 2016 at 1:10 pm #1267203Can you at least confirm that the swipe/swiperight/swipeleft events are or are not compatible or have .preventDefault() with X-Theme?
November 22, 2016 at 10:07 pm #1267718Hi 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!
-
AuthorPosts