Reputation: 3539
I'm developing a cross-platform application. I have a couple of swipe gestures for going to next/previous pages. The code looks like this:
var myself = this;
jQuery('body').on("swipeleft",function(event){
console.log('swipeleft');
if(myself.hasNextPage()){
myself.nextPage();
}
});
They work well on phone, however, it prevents me from highlighting any text on PC - the swipe event fires in the middle of highlighting! Is there a good way to suppress this event on PC?
Upvotes: 0
Views: 276
Reputation: 3539
This can be worked around by checking if there is currently a selection. If there is, then don't fire the function.
var myself = this;
jQuery('body').on("swipeleft",function(event){
console.log('swipeleft');
if(myself.hasNextPage() && (window.getSelection()+"").length === 0){
myself.nextPage();
}
});
Upvotes: 1