Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG interactivity on an iPad

Tags:

svg

ipad

We have code that loads SVG via Ajax and then interacts via Javscript. Under Mozilla, and under Safari 5, running on a PC we get click events as expected in SVG. Running Safari iPad we don't get click events. According to the Safari developer guide:

http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/CreatingContentforSafarioniPhone/CreatingContentforSafarioniPhone.html

it looks probable we should be 'Making Elements Clickable.' Apple's guide suggests one does this by adding an onclick handler. The problem is all our SVG elements already have a click handler set up via jQuery - and they still don't click.

Maybe this is because SVG is not HTML, and SVG's DOM access is not HTML DOM's access? (We've been here before.)

How do we get the iPad to listen for events on SVG elements?

like image 813
Tony Eastwood Avatar asked Nov 26 '25 13:11

Tony Eastwood


2 Answers

To my knowledge, there is a problem with safari according this javascript - which handles canvas/SVG It seems that click and touch is not the same. https://github.com/kangax/fabric.js/blob/master/dist/all.js And SVG 1.1 does not have other than click events http://www.w3.org/TR/SVG11/interact.html#PointerEventsProperty I have the same interest, therefore I seek the same information ...

like image 159
MikeyKennethR Avatar answered Nov 30 '25 18:11

MikeyKennethR


I was able to get click events working on Ipad using jquery and javascript. but my issue is that the svg blurs on an iPad.

My svg is embedded in an html object, then I just access it by calling a normal click event referenced to a function that access the svg component through:

window.top.document.getElementById('elementId');
like image 34
Carel Meyer Avatar answered Nov 30 '25 18:11

Carel Meyer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!