Skip to content

Commit

Permalink
stop the stuff from happening for normal clicks
Browse files Browse the repository at this point in the history
  • Loading branch information
kastner committed Apr 22, 2011
1 parent 71064fb commit 42fddd2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions jquery.gangZoom.js
Expand Up @@ -64,8 +64,6 @@
if (self.mouseDown) {
if (event.target == self.img || event.target == self.float[0]) {
self.go();
} else {
self.cancel();
}
}
})
Expand All @@ -85,9 +83,13 @@
self.img.mousedown(function (event) {
event.preventDefault();
self.shouldStopClick = false;
self.stopped = false;
var evt = event;

setTimeout(function () {
if (self.stopped) {
return;
}
evt.stopPropagation();
var clickX = evt.pageX;
var clickY = evt.pageY;
Expand Down Expand Up @@ -128,11 +130,15 @@
.mouseup(function (evt) {
if (self.mouseDown) {
self.go();
} else {
self.cancel();
}
})
.click(function (event) {
if (self.shouldStopClick) {
event.preventDefault();
} else {
self.stopped = true;
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion test.html
Expand Up @@ -55,6 +55,6 @@
<input type="text" id="datepicker-ce">
<span class="human"></span>
</div>
<img class="zoomable" src="http://cl.ly/1s1C0m1E0m45353i0u41/content"></img>
<a href="test.html" onclick="alert('foo'); return false;"><img class="zoomable" src="http://cl.ly/1s1C0m1E0m45353i0u41/content"></img></a>
</body>
</html>

0 comments on commit 42fddd2

Please sign in to comment.