Created
June 29, 2011 00:39
-
-
Save sdesai/1052580 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
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