user1211631
user1211631

Reputation: 11

cancelling an onclick with a mousemove

I'm not very technical so excuse the following question if it is not phrased properly.

Here it goes:

My site is built with the iscroll javascript so you can click and drag the site to browse. On the portfolio page which currently is the only other slide on from the homepage, I have a thumbnail viewer which enlarges the thumbnail to show the full image, this can be seen at test.silent-g.co.uk

The problem I have, is that when you click and drag to browse back a page, it still activates the viewer, is there a way to code in to the javascript, to cancel the onclick when the mouse is dragged or would this cancel the scroll too?

Excuse the site, the links aren't working and is only a work in progress.

Any thoughts welcome and if answers could be put into laymens terms that'd be great as although I can use javascript I can't write it.

Upvotes: 1

Views: 625

Answers (2)

Rick Hoving
Rick Hoving

Reputation: 3575

The onClick should work propperly. What I tried on jsfiddle was the following.

Html:

<button id="button" onClick="alert(1)">
    Your button
</button>

Then just click on the button drag your mouse away from the element and release the mouse. This doesn't trigger the onClick event.

Upvotes: 0

J&#248;rgen R
J&#248;rgen R

Reputation: 10806

I would suggest you replace onclick with mouseup. This way, it only acts if the user releases the mouse button when the cursor is placed on the element.

Upvotes: 0

Related Questions