Skip to content

Instantly share code, notes, and snippets.

@sdesai
Created June 29, 2011 00:39
Show Gist options
  • Save sdesai/1052580 to your computer and use it in GitHub Desktop.
Save sdesai/1052580 to your computer and use it in GitHub Desktop.
...
var content = scrollView.get("contentBox");
// Roll my own delegate to work around Chrome 12 issue (if you need click support that is).
content.on("click", function(e) {
// For mouse based devices, we need to make sure the click isn't fired
// at the end of a drag/flick. We're use 2 as an arbitrary threshold.
var tagName = e.target.get("tagName");
if (tagName && tagName.toLowerCase() === "img") {
if (Math.abs(scrollView.lastScrolledAmt) < 2) {
alert(e.target.getAttribute("alt"));
}
}
});
// Prevent default image drag behavior - not needed for Chrome. Mainly for Gecko,
// but not targeted to keep the example generic (it didn't hurt the other browsers)
/*
content.delegate("mousedown", function(e) {
e.preventDefault();
}, "img");
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment