abpetkov / switchery

iOS 7 style switches for your checkboxes
http://abpetkov.github.io/switchery/
2.05k stars 477 forks source link

Touch support #144

Open fracz opened 7 years ago

fracz commented 7 years ago

When you open a switch on a mobile device, you should be able to change its state with swipe gesture.

Creating a new issue because the previous one is very old #31 and I'm not sure the OP desired the same behaviour as I do.

It seems very natural to switch the handle by swiping.

Mr-Anonymous commented 6 years ago

I agree. I've had a few users, especially the ones using iPhones saying switchery doesnt work properly. They are trying to swipe and it doesn't work and they had to click it like its a button for it to work. Not everyone figures it out and they assume the swipe is not working properly.

AlexisVerdu commented 6 years ago

+1, I agree too.

decowboy commented 6 years ago

I'm experiencing the same issues with users being confused.

decowboy commented 6 years ago

As an ugly and overly simplistic work-around using jQuery, this works fine for me:

// Bind to touchend event of each switchery element
$(".switchery").on( "touchend", function(e) {
    // Prevent this touch triggering a click
    e.stopPropagation();
    e.preventDefault();

    // Manually trigger a click
    $(this).click();
});