Can *you* get SVG on mobile browser accept mouse/touch events? I can't

后端 未结 2 698
走了就别回头了
走了就别回头了 2021-02-19 09:38

I display an HTML, with an embedded SVG. I want it to detect mouse events, but it isn\'t working on the mobile (Android Jellybean). It works fine for a desktop browser.

2条回答
  •  我在风中等你
    2021-02-19 10:05

    I had that problem and it turns out the iPad considers the opacity of an object for its hit-test function, so if you have something with fill:none it won't register an event.

    I successfully tested a path with this style:

    .st5 {fill:none;fill-opacity:0.01;stroke:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:0.72}
    

    and two event handlers placed on the tag containing the path:

       ...path here with style .st5 
    

    the load(id) function is stored in an external JS file.

    Another catch is that the SVG has to be placed directly inside the HTML dom and not referenced as an , the latter causes security exceptions

提交回复
热议问题