I have the following event handling code:
$('#main').delegate('.slide', 'click', function () { slideshow.next(); }); $('#main').delegate('a', 'click', function (e) { e.stopPropagation(); });
.slide is a large div with content. slideshow.next() is called when .slide , unless a link is clicked, in which case stopPropagation() and .slide never receive a click event.
I would like to make it possible to select text on a slide. At the moment, if I click and drag when I release the mouse, the selection works, but .slide registers the click and runs the slideshow.next() function. Is there an event that I can intercept?
The page is available here .
Edit: Interestingly, if a selection spans more than one HTML element, click does not start, but the selection is inside the element, it starts.
Edit2: Ok, here is my solution:
function setupHandlers() { var prevX = 0; var prevY = 0; $('#main').delegate('.slide', 'click', function (e) { var clickTolerance = 2; var dx = Math.abs(e.pageX - prevX); var dy = Math.abs(e.pageY - prevY);
jquery events
Skilldrick
source share