Apparently, if you put a click listener on an element, you can no longer select the text inside that element in iOS. My solution was to detect taps using a combination of touchstart, touchmove, and touchhend events along with a timer to ignore multiple taps and check the current selection of the document to make sure that the selection event is not occurring.
Here is the JS code I used:
SingleTapDetector = function(element, handler) { this.element = element; this.handler = handler; element.addEventListener('touchstart', this, false); }; SingleTapDetector.prototype.handleEvent = function(event) { switch (event.type) { case 'touchstart': this.onTouchStart(event); break; case 'touchmove': this.onTouchMove(event); break; case 'touchend': this.onTouchEnd(event); break; } }; SingleTapDetector.prototype.onTouchStart = function(event) { this.element.addEventListener('touchend', this, false); document.body.addEventListener('touchmove', this, false); this.startX = this.currentX = event.touches[0].clientX; this.startY = this.currentY = event.touches[0].clientY; this.startTime = new Date().getTime(); }; SingleTapDetector.prototype.onTouchMove = function(event) { this.currentX = event.touches[0].clientX; this.currentY = event.touches[0].clientY; }; SingleTapDetector.prototype.onTouchEnd = function(event) { var that = this;
source share