Closed irace closed 11 years ago
I should note that 'mouseup' also appears to have the same behavior (prevents the user from selecting text).
Interesting (if this is true). You should know that observing a "click" event on a natively non-clickable element (in your case, "#container") on iOS changes the nature of that element slightly. You should definitely try to use tap events when possible. As for HTML5 audio player restrictions, I don't know. You should try it yourself.
I have tried it myself. Observing 'click' is the only way I am able to use JavaScript to pause/play the audio element. I would love to somehow be able to observe 'tap' and still have this ability, as to not screw with the native text selection capabilities.
Observing 'click' is the only way I am able to use JavaScript to pause/play the audio element.
That is bizarre. Are you sure it's not something in your code? Have you tried using native touch events (not ones provided by Zepto) such as "touchend"?
Using 'touchend' does fix the issue: it satisfies Mobile Safari's user-initiation policy (http://developer.apple.com/library/safari/#documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW4) but does not interfere with standard iOS text selection.
Thanks for the suggestion!
So, is the conclusion that one can't use Zepto-provided "tap" event to interact with Audio elements?
Yes, I believe so.
From Apple's documentation:
"This plays the movie: <input type="button" value="Play" onClick="document.myMovie.play()">
This does nothing on iOS: <body onLoad="document.myMovie.play()">"
Apparently Zepto's 'tap' event does not qualify as user initiated in the same way that 'click' events do.
FWIW, you can use "touchend" on iOS for this. Non-native or events generated in JavaScript can't do certain things like start playing audio or focusing a text field.
Closing stale ticket in favor of #805.
Using the 'click' event handler in the following fashion seems to break text selection on the iPhone.
This prevents the user from selecting text anywhere in the web view, not just the target element matched by the selector.
The reason I am listening for 'click' as opposed to 'tap' events is that HTML5 audio players can apparently only be played/paused from the former.
Please let me know if I'm simply doing something stupid :)