Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails when clicking on SVG graphics #22

Open
eirikurn opened this issue Feb 8, 2016 · 6 comments
Open

Fails when clicking on SVG graphics #22

eirikurn opened this issue Feb 8, 2016 · 6 comments

Comments

@eirikurn
Copy link

eirikurn commented Feb 8, 2016

This happens when the target of the touch events is a SVG element, e.g. a button/link that contains an SVG icon.

A JavaScript error occurs on e.target.click(), as svg elements don't have that method.

@eirikurn
Copy link
Author

eirikurn commented Feb 8, 2016

A workaround is set pointer-events: none; on the svg element.

@arschmitz
Copy link
Contributor

Hrm im not sure if we should actually do something here or just document this

@eirikurn
Copy link
Author

eirikurn commented Feb 8, 2016

Yeah, only "fix" I can think of now is:

var node = e.target;
while (node && !node.click) {
  node = node.parentNode;
}
if (node) node.click();

@arschmitz
Copy link
Contributor

@eirikurn pretty much but the css solution is a lot nicer but far less automatic

@wongpeiyi
Copy link

Am facing this on android browsers – however I'm thinking the dropHammer function should just be wrapped in a check for target.click. This way the default functionality is preserved should hammer-time not be able to fire:

  dropHammer: function( e ) {
    if ( e.target.click ) {
      if ( e.type === "touchend") {
        e.target.focus();

        // Wait for next tic so events fire in proper order
        setTimeout( function() {
          e.target.click();
        }, 0 );
      }

      // Prevent the click which will come after this otherwise but with a 300ms delay
      e.preventDefault();
    }
  },

I think this is preferable than making assumptions about clicking through to the parent?

@mydea
Copy link

mydea commented Oct 20, 2016

I am also experiencing this on an iPad. The pointer-events: none thing fixed it, but I also feel that this shouldn't break, but just fall back to 'regular' behavior in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants