Skip to content

PreventDefault on touch but not on mouse #2

@Macgyverman

Description

@Macgyverman

We've run into an issue where we need to prevent default on a touch, as the iphone will then trigger a mouse event too, thereby duplicating everything.

I've modified the library to include a configuration option called preventTouchDefault and preventMouseDefault.

And added the folllwing lines of code to replace

Original code:

if (options.preventDefault) {
event.preventDefault && event.preventDefault();
return false;
}

New code

isMouse=false;
if(event.type.match(/^mouse/))
isMouse=true;

            // prevent default handlers
            if ((options.preventTouchDefault && !isMouse) || (options.preventMouseDefault && isMouse)) {
                event.preventDefault && event.preventDefault();
                return false;
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions